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 trialAnurag k
902 Pointsletter game introduction
after finishing the program what make the program to guess the position or index of the letter and places it there ? can u please say like for apple I type 'l' then in output it comes ___le .what makes this happen ?
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsIn the while
loop:
# using the secret_word for the output pattern
for letter in secret_word:
# check each letter in the secret word...
if letter in good_guesses:
# if the letter has been guessed, print that letter
print(letter, end='')
else:
# if the letter has Not been guessed print a place holder character
print('_', end='')
# When all done looping over secret_word, print to get End of Line character
print('')
So as the "l" is guessed, it is added to the good_guesses
list and will then be printed in the above loop.
Post back if you have more questions. Good Luck!!