0

Problem with or operator

Hi, I have no idea what I'm doing wrong with the code below. When I enter to that program number 1 or 2, in answer I get a "False", but in my opinion I should get a "True" s = input("Enter a number: \n") print(s) print(s == 1 or s == 2)

22nd Jan 2019, 9:00 PM
mtechnic
3 Answers
+ 8
input returns a string so you should convert it to integer using 'int' function
22nd Jan 2019, 9:04 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 5
You are entering a string, but conditionally checking for an integer. Do: s = int(input("Enter a number: \n")) instead.
22nd Jan 2019, 9:04 PM
Dread
Dread - avatar
0
Thanks :)
23rd Jan 2019, 8:24 PM
mtechnic