RESOURCES:
Class slides: https://docs.google.com/presentation/d/17bTKwj8HQCmq1EYbqcVSvHgdymNR0GSEsGLoUmmK5Gc/edit?usp=sharing
Example code: https://replit.com/@ShravyaS/IntroToPython-18
HOMEWORK / MINI-PROJECT:
(Same as Class 16; use DICTIONARIES, not LISTS)
Write a program that can accept menu items and menu prices, until the word "done" is entered. Store each item and price in a dictionary. Then, print out everything together as a fancy menu.
ex:
duck
35
chopsticks
10
done
duck . . . . . . $35
chopsticks . . . . . . $10
Write your answer as a comment, and feel free to email the TAs (Shravya and Eric) if you're stuck. See you next class!
print("Welcome to Nasty Restraint") print("Would you like to help? (You have no choice)") print("Everything is a scam") dict = {} x=0 y=0 while x!="done" and y!="done": x=input() if x != "done": y=input() if y != "done": i=["$",y] dict[x]="".join(i) for i in dict: print(i,"......", dict[i]) dict = {}
Solution
dict = {} x=0 y=0 while x!="stop" and y!="stop": x=input() if x != "stop": y=input() if y != "stop": i=["$",y] dict[x] = "".join(i) for i in dict: print(i, "......", dict[i])