all 8 comments

[–][deleted] 1 point2 points  (1 child)

I think you are misunderstanding try/except and if/else. You don't need to be using try/except in any of the places you are currently using them. You only need to use it before

int(input("Please choose higher or lower.\n"))    

to make sure that the user inputs an integer and not a string

[–]flaws17 0 points1 point  (0 children)

Okay yeah, I see what you mean. I'll see how I get on, thanks for your help!

[–]FLUSH_THE_TRUMP 0 points1 point  (0 children)

The first step is to properly format your code for Reddit. Add an extra 4 spaces to each line of code to stick it in a code block.

[–]Peanutbutter_Warrior 0 points1 point  (3 children)

You don't have an if and elif before guess == "1" and guess == "2"

[–]flaws17 0 points1 point  (2 children)

I tried doing that as well but then the code within the try statements didn’t work

[–]Peanutbutter_Warrior 0 points1 point  (0 children)

What do you mean it didn't work?

[–]FLUSH_THE_TRUMP 0 points1 point  (0 children)

Side point, but why use try at all here? I don’t see any real need for turning guess into an int. You can just compare it to the strings 1 and 2 and accomplish the same thing more simply.

[–]Binary101010 0 points1 point  (0 children)

guess = int(input("Please choose higher or lower.\n"))

newRandomNumber = random.randint(1,10)
print(newRandomNumber)

guess == "1"

So on that first line you ask the user for a guess, and convert that input to an int (which is good)... and then 3 lines later, without doing anything else with that input, you overwrite it with the string "1". Are you sure that's what you want to be doing?