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

Python

In a word with multiple letter, length of good_guess is not equal to length of secret_word

For example:

secret_word = "strawberry"
len(secret_word) = 10
but len(good_guess) = 9 because there are 2 'r'
so it isn't end
How can I fix this?

I'm sorry, I'm not quite sure if I'm understanding the question.. Could you please post the code?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,468 Points

Good question. As you've figured out using the len() of a list doesn't work if the secret word has repeated letters. One way to get a quick list of unique characters is to convert the list to a set. Comparing the correct guess length to the len(set(secret_word_characters)) should suffice.

Post back if you need more help. Good Luck!!

I got it. Thank you!