When i run below command and give first input as 2 and second input as 100 it is giving- “!Yay” , where as 2 > 100 is false and should give “!Nyaa” . can you explain why please.
x= input()
y= input()
“!Yay” if (x > y) else “!Nyaa”
When i run below command and give first input as 2 and second input as 100 it is giving- “!Yay” , where as 2 > 100 is false and should give “!Nyaa” . can you explain why please.
x= input()
y= input()
“!Yay” if (x > y) else “!Nyaa”
First, you should check out the About the Users category post for how to format code in your posts.
Regarding your example:
input() returns a string (str) object, not a numeric type, so you’re comparing strings, not numbers. You could convert the input to numbers right away:
x = int(input())
y = int(input())
Or you could convert them later: if int(x) > int(y)