Skip to content

Commit 1e3f18c

Browse files
committed
pset3 code q2 & 3
1 parent 24dcd20 commit 1e3f18c

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

week3/grocery/grocery.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
list = []
2+
3+
while True:
4+
try:
5+
items = input().upper()
6+
except EOFError:
7+
print("")
8+
break
9+
else:
10+
list.append(items)
11+
12+
list.sort()
13+
14+
k = 0
15+
16+
for i in list:
17+
count = 0
18+
if k==0 or list[k] != list[k-1]:
19+
if list[k] != list[-1]:
20+
l = k
21+
while list[l] == list[l+1]:
22+
count += 1
23+
l +=1
24+
elif len(list) == 2 and list[k] == list[k-1]:
25+
count += 1
26+
print(count+1, i)
27+
28+
k += 1

week3/taqueria/taqueria.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
menu = {
2+
"Baja Taco": 4.00,
3+
"Burrito": 7.50,
4+
"Bowl": 8.50,
5+
"Nachos": 11.00,
6+
"Quesadilla": 8.50,
7+
"Super Burrito": 8.50,
8+
"Super Quesadilla": 9.50,
9+
"Taco": 3.00,
10+
"Tortilla Salad": 8.00
11+
}
12+
13+
cost = 0
14+
15+
while True:
16+
try:
17+
food =input("Input: ").strip().lower().title()
18+
if food not in menu:
19+
raise KeyError
20+
except KeyError:
21+
continue
22+
except EOFError:
23+
print("")
24+
break
25+
else:
26+
cost += menu[food]
27+
print(f"Total: ${cost:.2f}")

0 commit comments

Comments
 (0)