Advertisement
Andres_v

Untitled

Mar 4th, 2019
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #crea una lista según la cantidad de elementos que el usuario quiera
  2. shopping = []#lista vacía
  3. entrada = input("how many items of shopping are needed? ")
  4. subtotal = 0
  5. off = 0.1
  6. total= 0
  7. if entrada.isdigit():
  8. for item_number in range(int(entrada)):# para variable item_number in rango de 5 elementos, del 0 al 4
  9. 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
  10. if item.isalpha():
  11. price = input("what is the price of "+ item + "? ")
  12. if price.isdigit():
  13. shopping.append(item)#agrega a lista que estaba vacía shopping el valor ingresado
  14. subtotal = subtotal + int(price)
  15. total = subtotal*(1-off)
  16. else:
  17. print("Please, put a valid value")
  18. else:
  19. print("Please, put a valid value")
  20. print("Your list is " + str(shopping))
  21. print(str("There is ") + str(entrada) + str(" items in your shopping list, thanks for comming "))
  22. print("Your count is " + str(total) + " USD")
  23. print("You save " + str(subtotal-total) + " USD")
  24. else:
  25. print("Please, put a valid value")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement