-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary_problem_two.py
More file actions
29 lines (29 loc) · 971 Bytes
/
Copy pathdictionary_problem_two.py
File metadata and controls
29 lines (29 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'''Write a program that repeatedly asks the user to enter product names and prices. Store all of these in a dictionary
whose keys are the product names and whose values are the prices. Perform the following:
a) List the product names
b) List the prices
c) Display the product name that are >200 price
d) Display the price details of the product name starts with 'a'
'''
i=0
print("If you have to quit the process of entering give 0 in both inputs")
d={"item":[],"price":[]}
while i==0:
a=input("Enter the prdt name: ").upper()
b=int(input("Enter the prdt price: "))
if a=="0" and b==0:
break
d["item"].append(a)
d["price"].append(b)
#To list products and items
a=d["item"]
b=d["price"]
print("The product with price >200 is:")
for i in b:
if i>200:
pos=b.index(i)
print(a[pos])
print("The product that starts with a is ")
for j in a:
if j[0]=="A":
print(j)