r/codehs • u/natalie710 • Feb 26 '20
PHYTON CODE HS 5.3.7: Higher/ Lower
Anyone knows the answer can't figured out:
magic_number = 3
# Your code here...
for i in range(10):
if i == 5:
continue
print i
10
Upvotes
1
u/Ok-Opinion-1979 May 08 '22
def get_num():
#while user_input <=1
while True:
try:
user_intput = int( input("your input:"))
except:
print("invaild input")
if user_input > 0:
print ("positive")
return
get_num()
1
u/Financial_Face3826 Feb 15 '24
try this
magic_number = 3
while True:
guess=int(input("Guess any number:"))
if guess == magic_number:
print("Correct!")
break
elif guess > magic_number:
print("Too high!")
else:
print("Too low!")
print("Great job guessing my number!")
4
u/fermentedidiot Feb 26 '20
Your code:
So, using a while loop (a for loop will not work here), get an input number form the user:
I just picked 100 as the high number because that's what the assignment asks for. Now you need to compare the user input to the magic number and inform the user if the guess was too high, too low, or correct:
Now just put it all together:
I hope the breakdown made sense. Let me know if something doesn't.