Advertisement
Guest User

tip3

a guest
Dec 8th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # tip checking loop
  2. while True:
  3.     # tip value question - not defined as integer to be able to get empty value
  4.     answer = input("Give me the tip quantinty which you gave to Johnnemy 'hundred' Collins: ")
  5.     # check if the answer is a number
  6.     try:
  7.         number = int(answer) # int('') will also raise ValueError
  8.     except ValueError:
  9.         print('Please enter a number')
  10.         # there is no break here, so we will loop
  11.     else: # if the answer is a number - check how much it is
  12.         if number<0:
  13.             print("You're kidding me. Please enter a positive number")
  14.             # again, no break -- so loop
  15.         elif number==0:
  16.             print('ZERO?')
  17.             break
  18.         elif number < 100:
  19.             print('Johnny says: Next time I spit in your soup')
  20.             break
  21.         elif number >= 100:
  22.             print('Johnny says: SUPER!')
  23.             break
  24.  
  25. print('This is the end of this conversation')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement