I've looked over tutorials but don't particularly understand the concept.
I'm trying to get my while loop work with multiple conditions/if statements:
while True:
user_input = raw_input('\n: ').upper()
if user_input == 'NORMAL':
user_input = 'Normal'
if re.match('(ABC|Normal|XY)', user_input):
check_input = cleaned_dict.get(user_input)
if not check_input:
print 'Nope'
if check_input:
print 'Yep...'
etc...
break
However, I receive an error:
UnboundLocalError: local variable 'check_input' referenced before assignment
...Due to it not looping when the regex pattern does not match.
With only 1 condition it works perfectly.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire