Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Whelchel
2,096 PointsSyntax error
I am getting a syntax error for the end=' ' command
also, when I hit return at the beginning at get the following error:
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
import random
words = [
'apple'
'lemon'
'banana'
'orange'
'watermelon'
'coconut'
'strawberry'
'pineapple'
]
while True:
start = input("Press return/enter to start, Q to quit")
if start.lower() == 'q':
break
secret_word = random.choice(words)
bad_guesses = []
good_guesses = []
while len(bad_guesses) < 7 and len(good_guesses) != len(list(secret_word)):
for letter in secret_word:
if letter in good_guesses:
print(letter, end='')
guess = input("Guess a letter: ").lower()
2 Answers
Chris Freeman
Treehouse Moderator 68,454 PointsIt appears you are running python2 and not python3.
Also, the strings in words
should be separated by comma.
Post back if you need more help!
Shiyu Huang
891 PointsI ran.into the same error when running the script on Mac Terminal. It turned out that intead of typing "python letter_game.py" into the command line, type "python3 letter_game.py" instead resolved the issue for me!
Jonathan Whelchel
2,096 PointsJonathan Whelchel
2,096 PointsI was able to install python 3 on my Mac and my text editor...but I am still getting the same error.
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsCan you cut and paste the contents of the command or terminal window of the command and the error? Also, please try running Python interactively and post the header you see as the Python REPL starts up?
It may be that Python 2 is still being run.