16.Write a program that repeatedly asks the user to enter product name names and prices. Store all of
these in a dictionary whose keys are the product names and whose values are the prices
Answers
Answered by
2
Answer:
Python's dictionary class has three methods for this purpose. The methods items(), keys() and values() return view objects comprising of tuple of key-value pairs, keys only and values only respectively. The in-built list method converts these view objects in list objects.
Answered by
5
prices = {}
while True:
product, price = input("product: "), float(input("price: "))
prices[product] = price
print(prices)
Similar questions