1st Jun 2019, 1:49 AM
Farzam
Farzam - avatar
2 Réponses
+ 1
By default, the input() function returns a String type, so you are trying to compare a String to an integer, comparing two different variable types is not allowed without manipulation, so you can either declare x as an integer, or change each number operand in your if/elif statements to a String. If you want to compare two integers you can do that by replacing the first line with x = int(input()) or if you want to compare two Strings, leave the first line as you have it and put single quotation marks around each number operand IE: if x == ‘7’:
1st Jun 2019, 1:55 AM
Jake
Jake - avatar
+ 6
You need to convert input to int else it compares the input which is just a string '7'==7 x=int(input())
1st Jun 2019, 1:55 AM
Lord Krishna
Lord Krishna - avatar