0

How do I use input? (read description)

If I put something like this: iiS = input() if iiS == ['3', '4', '5'] print('HelpMe') if iiS == ['6', '9', '11'] print('Please') It says "No Output" when there should be if the user inputted 3, 4, 5, 6, 9, or 11, right? Can someone help me?

26th Mar 2017, 3:38 PM
privrax.
privrax. - avatar
3 Answers
+ 5
You are trying to compare the variable to the whole tuple or set, instead of checking if the input is in the set. Your if statement should use the syntax of: if iiS in ('2', '3', '4'): ...
26th Mar 2017, 7:15 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
If I put something like this: iiS = input() if iiS == ['2', '3', '4']: print('A') if iiS == ['18', '19', '20']: print('B') It doesnt print anything when i input anything on the two lists. If I do this: iiS = input() if iiS == ('2', '3' ,'4'): print('A') if iiS == ('18', '19', '20') I get both A and B What do I do?
26th Mar 2017, 4:02 PM
privrax.
privrax. - avatar
0
iiS = input() if iiS in ['2', '3', '4']: print('A') if iiS in ['18', '19', '20']: print('B') see the difference? this way checks if the number is IN the list you provide. iiS in ..... this will check a list to see if I contains an item. iiS == .... this will check for 1 specific item iiS in [1,2,3] iiS==1 iiS==2 This applies to both methods your trying to use iiS = input() if iiS in ('2', '3' ,'4'): print('A') if iiS in ('18', '19', '20'): print('B')
26th Mar 2017, 4:20 PM
LordHill
LordHill - avatar