+ 1

help me correct this simple code

hi this code is correct: x = 20 if x >= 20: print("You Win!") if x < 10: print ("you lose") but i cant use input: input ("what is your number?") x = input if x >= 20: print("You Win!") if x < 10: print ("you lose")

7th Dec 2017, 7:51 AM
Yusuf Nazari
Yusuf Nazari - avatar
2 Answers
+ 10
You've almost got it right. Just say x = int(input("what is your number?")) # corrected if x >= 20: print("You Win!") if x < 10: print ("you lose") [edit: Schindlabua is right - it should be x = int(input ("what is your number?")) to make your input an integer. Sorry for the confusion.]
7th Dec 2017, 7:56 AM
David Ashton
David Ashton - avatar
+ 7
x = int(input("What is your number?")) should do the trick. input() gives you a string, which you need to convert to a number first using int().
7th Dec 2017, 7:55 AM
Schindlabua
Schindlabua - avatar