Advertisement
Guest User

Input Counter

a guest
Jan 18th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. def Count_inputs (inputx, count):
  2.     if inputx in ("y", "Y", "yes", "YES"):
  3.         return count + 1
  4.     elif inputx in ("n", "N", "no", "NO"):
  5.         return count
  6.     else:
  7.         #Catch all other out comes
  8.         print ("Answer Unclear. Use 'y' or 'n'")
  9.         return count
  10.  
  11. count = 0
  12. while True: #Infinite Loop
  13.     newinput = input("Keep going [y/n]? ")
  14.     count = Count_inputs(newinput, count)
  15.     print(f"Count is {count}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement