This is a snippet from my script.
while True:
## Rules: userInput == [isalpha()=True, isdigit()=True, True, isdigit()=True]
userInput = raw_input('# ').replace(' ', '').split(',')
print userInput
print 'List Index 0', userInput[0].isalpha()
print 'List Index 1', userInput[1].isdigit()
print 'List Index 3', userInput[3].isdigit()
print 'List is', userInput[0].isalpha() and userInput[1].isdigit() and userInput[3].isdigit()
if userInput[0].isalpha() and userInput[1].isdigit() and userInput[3].isdigit() == False:
print 'Error'
continue
else:
print 'Success'
break
And this is the output I get if I run it with input: 1,1,1,1
# 1,1,1,1
['1', '1', '1', '1']
List Index 0 False
List Index 1 True
List Index 3 True
List is False
Success
As far as I know the if statement is True and should be executed and return to the beginning of the loop until the rules are satisfied. However, the else statement gets executed instead.
What am I missing?
Thank you for your help.