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 Python Basics (Retired) Pick a Number! Any Number! The Solution

Can't solve Number Game Error

I cannot figure out what is wrong with my code. I keep getting a syntax error on line 24 which is: print("It took you {} guesses.".format(len(guessed_nums))))

What is wrong with this line?

if player_num == rand_num: print("You win! My number was {}.".format(rand_num) print("It took you {} guesses.".format(len(guessed_nums))) break

3 Answers

I noticed that a parentheses ) was missing on the first print action call by the if statement! otherwise I would need to look at more of your code to determine otherwise! Hope this helps!

if player_num == rand_num: print("You win! My number was {}.".format(rand_num))
print("It took you {} guesses.".format(len(guessed_nums))) break

Thanks seems to be working fine now

glad it's working for ya

Tommy Gebru
Tommy Gebru
30,164 Points

Hey Daniel,

Be sure to select Best Answer to close out a discussion thereby guiding students to similar solutions and keeping the forum organized. 'Hope this helps