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 trial
Michelle Wood
1,667 Pointsletter_game.py
I don't have the final program completed - and trying to build and test as I go.
getting the following error: good_guesses.append(guess) AttributeError: 'list' object has no attribute 'append' I'm obviously missing something and would benefit from someone taking a look...thanks.
#DONE_create list of words
#DONE_pick a random word
#draw spaces for letters
#take a guess
#draw guesses and strikes
#print out win or lose
import random
words = [
'blizzard',
'thundersnow'
'frostbite',
'squall',
'warning',
'snowball',
'bombogensis',
'sleet',
'shovel',
'boots',
'snowhoes',
'advisory'
]
while True:
start = input("Press enter/return to start, or enter Q to quit.")
if start.lower() == 'q':
break
#pick a random word
secret_word = random.choice(words)
bad_guesses = []
good_guesses = []
#print guess letter, space and strike
while len(bad_guesses) < 5 and len(good_guesses) != len(list(secret_word)):
for letter in secret_word:
if letter in good_guesses:
print(letter, end="")
else:
print("_", end="")
print("")
print("Strikes: {}/5".format(len(bad_guesses)))
print("")
#Get guess and compare to secret_word
guess = input("Guess a letter: ").lower()
if guess in secret_word:
good_guesses.apppend(guess)
if len(good_guesses) == len(list(secret_word)):
print("You win! The word was {}".format(secret_word))
break
else:
bad_guesses.append(guess)
else:
print("You didn't guess it! My secret word was {}.".format(secret_word))
2 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou spelled append with too many p's.
good_guesses.apppend(guess)
carolechang
iOS Development Techdegree Student 10,425 Pointsimport os
import time
now = time.strftime('%Y-%m-%d %H:%M:%S')
print now
def hello():
print 'hello,world'
Michelle Wood
1,667 PointsMichelle Wood
1,667 PointsThanks much James - you're the best. I starred at the screen far too long.