0

Im trying to get user input for my script. And the User input can only be 2 characters a dot(".") or a dash("-") I got it to check if its either of the characters the first time and it works. But If you for example put in a "b" itll then say invalid character and retry the input. Only problem is that if u put in a invalid character twice in a row it somehow thinks its a valid character a valid Character being a "." or "-" only.

Current Code:

character_a = input('Enter First Dot or Dash (. / -): ')

if not character_a == ".":
    if not character_a == "-":
        print('Invalid Character.. Try Again')
        character_a = input('Enter First Dot or Dash (. / -): ')
        

if character_a == "." or "-":
    print('Valid Character')
Jelloies
  • 1
  • 1

0 Answers0