I have the following rather simple if statement in Python 3.3.4, it works as it is but surly it can be simplified:
if ans is '1':
ans = int(ans)
ans = (opt[ans])
elif ans is '2':
ans = int(ans)
ans = (opt[ans])
elif ans is '3':
ans = int(ans)
ans = (opt[ans])
I have tried various combinations of this:
if ans is '1' or '2' or '3':
ans = int(ans)
ans = (opt[ans])
or this,
if ans == '1' or '2' or '3':
ans = int(ans)
ans = (opt[ans])
or this,
if ans is ('1') or ('2') or ('3'):
ans = int(ans)
ans = (opt[ans])
I have even tried using dictionaries but most combinations will just allow through any string for 'ans'; am I being silly and missing something really simple or is this not possible? Thanks in advance.