Advertisement
ladokhamuji

asd

Apr 7th, 2025
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | Source Code | 0 0
  1. total_price = 0
  2. item_count = 0
  3. items = []
  4. discount = 0
  5. delivery_fee = 0
  6. print("If you have short item or want to end in half way then press 0")
  7. print()
  8. while item_count < 10:
  9.  
  10.     print("Enter the price of the item (only positive number is accepted:")
  11.     price = float(input())
  12.  
  13.     if price == 0:
  14.         break
  15.     elif price < 0:
  16.         print("Not valid ! price should be in positive number only.")
  17.         continue
  18.  
  19.     print("Enter the name of the item:")
  20.     item_name = input()
  21.     print("Enter the quantity of the item (positive number only):")
  22.     quantity = int(input())
  23.  
  24.     if quantity <= 0:
  25.         print("Error: Quantity must be positive.")
  26.         continue
  27.  
  28.     items.append({
  29.         "name": item_name,
  30.         "price": price,
  31.         "quantity": quantity
  32.     })
  33.  
  34.     total_price += price * quantity
  35.     item_count += 1
  36.  
  37. if total_price == 0:
  38.     print("Error: No valid items entered. Please retry.")
  39. else:
  40.     if total_price > 100:
  41.         discount = total_price * 0.1
  42.         total_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement