Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.68 KB | None | 0 0
  1.     elif selection == "1":
  2.         sn = str(input("Enter the Serial Number : "))  # user enters a SN
  3.         arrayIndex = 0  # used for later
  4.  
  5.         if len(newSn) != 0:  # only if newSn has data inside then we have to check for duplicates
  6.             for i in newSn:
  7.                 if i == sn:  # if inside the newSn already has the SN user has typed
  8.                     arrayIndex = newSn.index(i)  # get the index of where the duplicate SN was found
  9.                     quantity = int(input("Enter the quantity of the ticket : "))  # only change quantity since same SN
  10.                     newQuantity[arrayIndex] = quantity  # find the quantity of the same index to change
  11.                     newQuantity = list(map(int, newQuantity))
  12.                     break  # break so it doesnt continue checking
  13.                 elif i == newSn[-1]:  # newSn[-1] means the last item in the list, this means that we have reached the last item and there is no duplicate so we must add new data
  14.  
  15.                     title = str(input("Enter the title of the Concert : "))  # user enters title
  16.                     price = int(input("Enter the ticket Price : "))  # user enters price
  17.                     quantity = int(input("Enter the quantity of the ticket : "))  # user enters quanitty
  18.  
  19.                     priceofTotalTickets += (price * quantity)
  20.  
  21.                     newTitle.append(title)  # add the new data
  22.  
  23.                     newPrice.append(price)  # add the new data
  24.  
  25.                     newQuantity.append(quantity)  # add the new data
  26.  
  27.                     newSn.append(sn)  # add the new SN
  28.                     break  # break so it doesnt continue the loop since we are already done
  29.  
  30.         else:
  31.             #  here happens because newSn is empty and we have to add our first ticket!
  32.             title = str(input("Enter the title of the Concert : "))
  33.             price = int(input("Enter the ticket Price : "))
  34.             quantity = int(input("Enter the quantity of the ticket : "))
  35.             priceofTotalTickets += (price * quantity)
  36.             newTitle.append(title)
  37.             newPrice.append(price)
  38.             newQuantity.append(quantity)
  39.             newSn.append(sn)
  40.  
  41.     # you can use this to see the amount of data you have entered
  42.     elif selection == "6":
  43.         print("Serial Number:", newSn[0])
  44.         print("Title:", newTitle[0])
  45.         print("Price:$", newPrice[0])
  46.         print("Quantity:", newQuantity[0])
  47.         print("-----")
  48.         # to see the second item, uncomment if you wanna try and see
  49.         #print("Serial Number:", newSn[1])
  50.         #print("Title:", newTitle[1])
  51.         #print("Price:$", newPrice[1])
  52.         #print("Quantity:", newQuantity[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement