techwithtim / 5-Python-Projects-For-Beginners

415 stars 235 forks source link

Number Guesses - does not print "type a number larger than 0" #26

Closed pritchardcm closed 9 months ago

pritchardcm commented 9 months ago

when I type a number that is < 0,

it prints "please choose a number next time"

instead of

"please choose a number larger than zero"

Adamsbag commented 9 months ago

Removes a leading minus sign (for negative numbers) by using the method ".lstrip". Your code should look like this;

if top_of_range.lstrip('-').isdigit(): top_of_range = int(top_of_range)

Let me know how it goes...

pritchardcm commented 9 months ago

This solved the issue! Thank you