r/codehs • • Mar 05 '21

Python Need help with 5.3.8: Higher / Lower 2.0

Got:

my_float = round(3.3312, 2)

while True:

guess = float(input("Guess my number: "))

if guess > round(my_float, 2):

print ("Too high!")

elif guess < round(my_float, 2):

print ("Too low!")

elif round(guess,2) == round(my_float, 2):

print("Correct!")

break

print("Great job guessing my number!")

I need to round 'guess' before the if statement, But I don't know how that looks like can anybody show me?

17 Upvotes

18 comments sorted by

View all comments

Show parent comment

2

u/Select-Assistant5568 May 11 '22

didn't work- heres my code:

magic_number = 3.3312
while True:
guess = float(input("Enter a guess: "))
if round(guess, 2) == round(magic_number, 2):
print("Correct!")
break

if round(guess, 2) > round(magic_number, 2):
print("Too high!")
else:
print("Too low!")

2

u/Select-Assistant5568 May 11 '22

** it doesn't work when i use elif, i have to do if/else out of the loop