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

Guessing Game: ValueError: Arg is an empty sequence.

Hello still working on the guessing game. I created a game function separate from the start_game function in order to make a play_again function. Also, in the start_game function, I set conditions to append the correct guessed value into the list, and for the lowest number(high_score) to display when the game is over. I want to know if 1) I am on the right path with creating a play_again function, and 2) why I am getting the empty sequence error for the high score?

My code: https://w.trhou.se/xnyg3yt2qp

2 Answers

Steven Parker
Steven Parker
229,788 Points

Look at lines 45 and 46 together:

    score = []
    max_score = max(score)

Clearly, the score was just assigned an empty list (empty sequence), and then it is being passed as the argument to the max function, causing the error.

Based on the message that will be issued later, it looks like you were intending for score to contain a list of the results of past games instead of being freshly emptied.

Steven Parker, I fixed the sequence, but now it is returning a Type Error: Non-Type is not an iterable object. My question is why is the list still empty? My code is as follows: https://w.trhou.se/8g3lezedco. Can you pay attention to the play_again function specifically lines 50-55. Thank you!

Steven Parker
Steven Parker
229,788 Points

The append method doesn't return anything, so the line score = score.append("num_guess") first adds a string to score but then the assignment makes it nothing. Not an empty list, but a "NoneType" (something with no value).

Steven Parker How would I fix it, like return a list full of numbers?

@steven I fixed it!