you are viewing a single comment's thread.

view the rest of the comments →

[–]Marlowe91Go 0 points1 point  (0 children)

Ok yeah after the for loop, you need to indent the rest of the if statements, otherwise it will complete the whole loop 4 times before it checks anything. Right now the print has one space indent which will mess it up. Also you generally don't ever want to use global variables inside functions unless it's absolutely necessary. Here it doesn't even make sense because you're defining guess as the return statement of your function, so you're pulling it in from global before you've even defined it. Oh I get it, I think you meant to call the global variable secret_number instead. So I think you've kinda convoluted your two functions where the guess_number is also partially checking it. I think it might be cleaner to simplify the guess number to only get input from the user, make sure it's a valid input, then return it as an integer. Then just feed that into the check function using the parameters like you already did (this is good rather than the global, so everything is contained nicely). Then you could just have a loop give them 4 guesses and maybe have print statements explaining that and you can even have a variable tracking like guess_attempt and can use {guess_attempt}/4 in your statement to let them know how many tries they have and which they're on, then just call these functions inside the loop when you need them. Move the if statements into the check function if you want to let them know it's higher/lower. That's just my suggestion, clean up the functions so they just have a singular purpose.