0

I just tryed an if statement in the code playground. But im lost on how to get the variable to work. Take a look!

plz help. it in me codes https://code.sololearn.com/cMkFBga31cit/?ref=app

8th Jun 2017, 7:57 PM
Edward Seton
Edward Seton - avatar
4 odpowiedzi
+ 4
Don't forget to take care of what happens if x = 8. print("Hello world!") x = int(input("Enter your favorite number!")) if x > 8: print("That's bigger than 8!") elif x < 8: print("That's lower than 8!") else: print("That's 8!") print("End program.")
9th Jun 2017, 3:14 AM
David Ashton
David Ashton - avatar
+ 3
print ("hello world") x = int(input("enter your faveoret number!")) if (x)>8: print ("thats bigger than 8") else: print ("thats lowr than 8!") print ("end program") Some stuff to remember. input() by default is a string. even if you get a number. your not getting 5 you are getting "5" .. To compare a number input to a number like 8 you have to either get it as int(input()) or get it like x=input() then change it to an int. x=int(x)... Or you could do it directly in your if statement. If int(x)>8 ... Other than that, your : goes after your if statement and what to do if your if statement returns true goes on the next like 4 spaces in.
8th Jun 2017, 10:26 PM
LordHill
LordHill - avatar
0
the ":" after the if has to be after the condition and I would make line breaks after the if- and else-clauses
8th Jun 2017, 8:38 PM
Arthur Fibich
Arthur Fibich - avatar
0
no. i just tryed that and it dont work
8th Jun 2017, 9:27 PM
Edward Seton
Edward Seton - avatar