Can somebody please help me with the if statement and arrays. So for example I type in 0001 in the array "1" is [3]. I’m trying to get it to print "working" if 1 is typed on array [3].
This code should explain it more:
original = raw_input("Type is your input? ")
original_as_array = list(original)
print original_as_array
print original[3]
if (original[3] == 1):
print "working"
This is because you are comparing an
intwith a single character (typestr). Change yourif-statement to:and it will work.
Your input from the key consists of characters (
'0001'), so your comparison has to take that into account.E.g.,