Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. ticketsLeft = 100
  2. transactions = 0
  3.  
  4. while ticketsLeft > 0:
  5.     print('# of tickets')
  6.     ticketsNow = int(input())
  7.     if ticketsLeft == 0:
  8.         break
  9.     if ticketsNow > ticketsLeft:
  10.         print('there are only ' + str(ticketsLeft) + ' tickets left')
  11.         continue
  12.     if ticketsNow <= int(4):
  13.         print('you bought ' + str(ticketsNow) + ' tickets')
  14.         ticketsLeft = ticketsLeft - ticketsNow
  15.         transactions = transactions + 1
  16.     else:
  17.         print('You can only purchase 4 tickets at a time')
  18. print('no tickets left')
  19. print('There were ' + str(transactions) + ' transactions.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement