Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #crea una lista según la cantidad de elementos que el usuario quiera
- shopping = []#lista vacía
- entrada = input("how many items of shopping are needed? ")
- subtotal = 0
- off = 0.1
- total= 0
- if entrada.isdigit():
- for item_number in range(int(entrada)):# para variable item_number in rango de 5 elementos, del 0 al 4
- item = input("what is the item " + str(item_number) + "? ")#variable item pregunta al usuario cuál es el item que desea agregar y lista la cantidad ingresada
- if item.isalpha():
- price = input("what is the price of "+ item + "? ")
- if price.isdigit():
- shopping.append(item)#agrega a lista que estaba vacía shopping el valor ingresado
- subtotal = subtotal + int(price)
- total = subtotal*(1-off)
- else:
- print("Please, put a valid value")
- else:
- print("Please, put a valid value")
- print("Your list is " + str(shopping))
- print(str("There is ") + str(entrada) + str(" items in your shopping list, thanks for comming "))
- print("Your count is " + str(total) + " USD")
- print("You save " + str(subtotal-total) + " USD")
- else:
- print("Please, put a valid value")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement