+ 1

I have to use 'x' variable as user input

x = input ("enter the number: ") if x == 5: print("Yes") else: print("No") is this program is write.

5th Jun 2018, 5:34 AM
arya
11 RĂ©ponses
+ 3
I got what u need(found on google)....its int() use it to convert input into an integer. x = int(input("inputs here")) and use float() if u want to convert it into a float
5th Jun 2018, 6:08 AM
Rohit
Rohit - avatar
+ 2
try this simpler example: x = 4 if x == 5: print("Yes") else: print("No") with this you should get output.
5th Jun 2018, 5:50 AM
Haris
Haris - avatar
+ 2
I tried your code as you've posted it and it works perfectly on my phone. đŸ€”
5th Jun 2018, 5:54 AM
Haris
Haris - avatar
+ 1
Correct logic, idk about the syntax though. Which language will you write this in? If it's python I think it's correct.
5th Jun 2018, 5:46 AM
Haris
Haris - avatar
+ 1
I think it is because input takes the user inputs as a string but u are comparing it with a number so its never equal....maybe firsy try converting that input into a number.....idk about python so cant help in that
5th Jun 2018, 6:00 AM
Rohit
Rohit - avatar
0
It is correct.
5th Jun 2018, 5:42 AM
Paul Grasser
Paul Grasser - avatar
0
but it's not working
5th Jun 2018, 5:46 AM
arya
0
it's python only .. I am not getting output
5th Jun 2018, 5:48 AM
arya
0
thans bro that will works I know but I need X variable as a user input
5th Jun 2018, 5:55 AM
arya
0
thans bro it's working
5th Jun 2018, 6:25 AM
arya
0
is it java language.
6th Jun 2018, 6:50 AM
Gurdeep
Gurdeep - avatar