fork(1) download
  1. # your code goes here
  2. def get_input():
  3. my_var = str(input('Enter "a" or "b": '))
  4. if my_var == "a" or my_var == "b":
  5. print('got input:', my_var)
  6. return my_var
  7. else:
  8. print('You didn\'t type "a" or "b". Try again.')
  9. return get_input()
  10.  
  11.  
  12. def get_input1():
  13. my_var = input('Enter "a" or "b": ')
  14.  
  15. if my_var != "a" and my_var != "b":
  16. print('You didn\'t type "a" or "b". Try again.')
  17. return get_input1()
  18. else:
  19. return my_var
  20.  
  21. print('got input:', get_input1())
  22.  
  23. #get_input()
  24.  
Runtime error #stdin #stdout #stderr 0.01s 7396KB
stdin
Standard input is empty
stdout
Enter "a" or "b": 
stderr
Traceback (most recent call last):
  File "prog.py", line 21, in <module>
  File "prog.py", line 13, in get_input1
EOFError: EOF when reading a line