Сделайте так, чтобы пользователь вводил название товара и его цену в одной строке.
Например, "Macbook 1500".
питон
my_basket = {}
ware_1 = input("product name - ")
my_basket[ware_1] = int(input("value - "))

ware_2 = input("product name - ")
my_basket[ware_2] = int(input("value - "))

ware_3 = input("product name - ")
my_basket[ware_3] = int(input("value - "))

ware_4 = input("product name - ")
my_basket[ware_4] = int(input("value - "))

ware_5 = input("product name - ")
my_basket[ware_5] = int(input("value - "))
total_cost = sum(my_basket.values())
print('We bought these goods:')
print('ware -', my_basket.popitem())
print('ware -', my_basket.popitem())
print('ware -', my_basket.popitem())
print('ware -', my_basket.popitem())
print('ware -', my_basket.popitem())
print("Total cost -", total_cost)
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.