Output becomes jumbled when running my program.py

Answered

When running my code that I am creating in the PyCharm editor, I am running into some issues. When I press run, the program will run just fine and bring up the text that I tell it to output, but the text doesn't appear in the correct order.

Like so:

It should output something like this:

This issue just began happening today when I moved the .py file to a new location. I am fairly new to the PyCharm editor so I am probably doing something very obviously wrong, but I can't locate anyone with similar issues online, at least I don't know what to search for. I have also tried opening the .py file from it's original location where it did work in the past but it doesn't even work there anymore.

1
8 comments
Avatar
Permanently deleted user

Here is another example of the jumbled output:

And here is my code:

import random


clear = "\n" * 50


def hangman():
words = ("python", "coding", "banjo", "fjord", "boxer", "comedy", "photography", "ivory", "quad")
secret = random.choice(words)
blanks = []

print('--Welcome to Hangman, there are two available modes--'
'\n 1. Single Player mode, guess a random word created by the computer'
'\n 2. Multiplayer mode, one player creates the word, the other guesses'
'\n')

gamemode = input('Choose your gamemode 1 or 2: ')
print('----------------------------------')

if gamemode == ('1') or ('2'):
if gamemode == ('1' or 'one' or 1):
print("You have chose Single Player, let's begin.")

print('The word is', len(secret), 'letters long')

for i in range(5):
letter = input('Guess a letter: ')
if letter in secret:
print('O Correct! "', letter, '" is in the secret word. \n')

else:
print('X Incorrect. "', letter, '" is not in the secret word \n')

if gamemode == ('2' or 'two' or 2):
print("You have chose Multiplayer, let's begin.")

secret = input('Player 1 enter the secret word.')
print(secret)

print('----------------------------------')
print('All of your guesses are up')
want = input('Do you want to guess the word Y/N? ')

if want == ('y' or 'yes'):
guess = input('Please type your guess: ')
if guess == secret:
print('CONGRATULATIONS YOU WON!')
else:
print('Incorrect. The word was: ', secret)
print('\n')
again = input('Want to play again Y/N? ')
if again == ('y' or 'yes'):
print(clear)
hangman()
else:
print('Thanks for playing!')
else:
print('Sorry, but the word was: ', secret)
print('\n')
again = input('Want to play again Y/N? ')
if again == ('y' or 'yes'):
print(clear)
hangman()
else:
print('Thanks for playing!')

else:
print(clear)
print('That was not a valid response, please try again.')
hangman()

hangman()
0

Hi Jdelfosse! Could you please specify what PyCharm version and color theme are you using?

0
Avatar
Permanently deleted user

Community Edition 2017.1.4 

Darcula

0

I mean Editor color scheme which is also used for run window. It doesn't look like Darcula. Do you have "Emulate terminal in output console" option enabled in Run Configuration for this script?

1
Avatar
Permanently deleted user

Yes I do have Emulate terminal in output console enabled, and I do not know how to check the theme for just the editor, I looked in settings and I saw Darcula under Appearance and Behavior

0
Avatar
Permanently deleted user

Pavel, So I disabled the Emulate Terminal option and this seemed to have fixed my issue. However, I was wondering why this option would cause my script to become jumbled like this, if it was working fine with the option enabled previously.

1

This should indeed works correctly, I created a ticket in our tracker PY-24787. Meanwhile this option is not supposed to be used on windows, it's available to user by mistake. You can check editor color scheme in Settings | Editor | Color Scheme but it has nothing to do with the problem as we discovered.

1
Avatar
Permanently deleted user

Ok thanks for the help! I am running on Windows 10 by the way.

1

Please sign in to leave a comment.