+ 1

num = input ("Please input 5 or 7 or 11 :") if num == 5: print("Number is 5") elif num == 11: print("Number is 11") elif

please I don't know why does not it work ? https://code.sololearn.com/cBqTmNuWSd4H/?ref=app https://code.sololearn.com/cBqTmNuWSd4H/?ref=app

5th May 2017, 1:33 PM
Hamada Hellal
Hamada Hellal - avatar
4 Respuestas
+ 10
This should work sir: num = input("Please input 5 or 7 or 11 :") num = int(num) if num == 5: print("Number is 5") elif num == 11: print("Number is 11") elif num == 7: print("Number is 7") else: print("Number isn't 5, 11 or 7") The reason it didn't work is the input data type is string in default
5th May 2017, 1:36 PM
Complex
Complex - avatar
+ 1
Nuber is 5
13th May 2017, 6:08 AM
real
0
the input function returns a string, So we must convert it to integer.
5th Sep 2017, 11:52 AM
Hamada Hellal
Hamada Hellal - avatar
0
hi
11th Feb 2020, 9:41 AM
ali amaar hussain
ali amaar hussain - avatar