At the moment I have a check to see if a string has specific characters in it.
I am trying to find a work around for a ‘Goto’ function.
This is what I have at the moment:
chars = set('0123456789$,')
if any((c in chars) for c in UserInputAmount):
print 'Input accepted'
else:
print 'Invalid entry. Please try again'
I just need Python to go back to the string input of ‘UserInputAmount’ if the entry is invalid. A push in the right direction would be appreciate.
You don’t need a goto, you just need a loop. Try this, which loops forever unless the user provides valid input: