-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrocery.py
56 lines (44 loc) · 1.39 KB
/
grocery.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
products = ["Sensodyne-100,Close Up-150,Colgate-135",
"Safeguard-80,Protex-50,Kojic-135",
"Surf-280,Ariel-350,Tide-635",
"Clover-60,Piattos-20,Chippy-35",
"Jelly bean-60,Hany-20,Starr-35"]
toothpaste=[]
bathsoap=[]
detergent=[]
chips=[]
candies=[]
categories = [toothpaste, bathsoap, detergent, chips, candies]
for x in range(len(products)):
categories[x].append(products[x])
#categories[x] = products[x].split(",")
for i in range(len(categories[x])):
categories[x][i] = categories[x][i].split(",")
for j in range(len(categories[x][i])):
categories[x][i][j] = categories[x][i][j].split("-")
toothpaste2=[]
bathsoap2=[]
detergent2=[]
chips2=[]
candies2=[]
categories2 = [toothpaste2, bathsoap2, detergent2, chips2, candies2]
item_price=()
for z in range(len(categories)):
for a in range(len(categories[z])):
for b in range(len(categories[z][a])):
item_price = (int(categories[z][a][b][1]), categories[z][a][b][0])
categories2[z].append(item_price)
toothpaste2.sort()
bathsoap2.sort()
detergent2.sort()
chips2.sort()
candies2.sort()
cheapitems=[]
cheapitems.append(toothpaste2[0])
cheapitems.append(detergent2[0])
cheapitems.append(bathsoap2[0])
cheapitems.append(candies2[0])
cheapitems.append(chips2[0])
print(cheapitems)
total = toothpaste2[0][0] + bathsoap2[0][0] + detergent2[0][0] + chips2[0][0] + candies2[0][0]
print(total)