Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- elif selection == "1":
- sn = str(input("Enter the Serial Number : ")) # user enters a SN
- arrayIndex = 0 # used for later
- if len(newSn) != 0: # only if newSn has data inside then we have to check for duplicates
- for i in newSn:
- if i == sn: # if inside the newSn already has the SN user has typed
- arrayIndex = newSn.index(i) # get the index of where the duplicate SN was found
- quantity = int(input("Enter the quantity of the ticket : ")) # only change quantity since same SN
- newQuantity[arrayIndex] = quantity # find the quantity of the same index to change
- newQuantity = list(map(int, newQuantity))
- break # break so it doesnt continue checking
- 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
- title = str(input("Enter the title of the Concert : ")) # user enters title
- price = int(input("Enter the ticket Price : ")) # user enters price
- quantity = int(input("Enter the quantity of the ticket : ")) # user enters quanitty
- priceofTotalTickets += (price * quantity)
- newTitle.append(title) # add the new data
- newPrice.append(price) # add the new data
- newQuantity.append(quantity) # add the new data
- newSn.append(sn) # add the new SN
- break # break so it doesnt continue the loop since we are already done
- else:
- # here happens because newSn is empty and we have to add our first ticket!
- title = str(input("Enter the title of the Concert : "))
- price = int(input("Enter the ticket Price : "))
- quantity = int(input("Enter the quantity of the ticket : "))
- priceofTotalTickets += (price * quantity)
- newTitle.append(title)
- newPrice.append(price)
- newQuantity.append(quantity)
- newSn.append(sn)
- # you can use this to see the amount of data you have entered
- elif selection == "6":
- print("Serial Number:", newSn[0])
- print("Title:", newTitle[0])
- print("Price:$", newPrice[0])
- print("Quantity:", newQuantity[0])
- print("-----")
- # to see the second item, uncomment if you wanna try and see
- #print("Serial Number:", newSn[1])
- #print("Title:", newTitle[1])
- #print("Price:$", newPrice[1])
- #print("Quantity:", newQuantity[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement