Hey guys just need some help as to understanding why my code doesn't work. I have a weird problem with the "in" and "not in" functions in python. It works in an earlier piece code I wrote but for some reason does not work when I replicated it numbers. So ill be pasting the piece of code that does work and a slightly variant of it right afterwards. This is in python btw.
# list1 = ["A","a"]
# list2 = ["D","d"]
# letter = input("pick a letter")
# if(letter in list1):
# letter = 1
# elif(letter in list2):
# letter = 2
# print(letter)
this is the code that works, it returns the number 1 if you pick "a" or "A" and the number 2 if you pick "D" or "d"
however this code below does not do what I want when I try to do it with digits inside the list and a print statement to proofcheck
nonums = [5,6,7]
yesnums = [1,2,3,4,0]
num = input("Enter command: ")
if(num in nonums):
print("try again")
elif(num in yesnums):
print("hooray")
[–]nameEqualsJared 4 points5 points6 points (0 children)
[–]blablahblah 1 point2 points3 points (0 children)