Let's improve the Beer Calories program from the previous unit. The data file is called NYC0-beer-calories.txt
Load the beer names and calories into two lists respectively. Use two more lists to keep track of the beers you drank and calories consumed.
Then write a program which:
loops until you enter 'quit' each time recording the name of the beer and its calories in the consumed lists.
After you type quit print out all the beers you drank and the total calories.
Sample run :
This program will tell you the total calories of the beers you drank.
Enter the beer you drank, or type quit: Budweiser
- Added Budweiser with 145.0 to your drink list.
Enter the beer you drank, or type quit: Miller Light
- Beer named Miller Light is not in the list.
Enter the beer you drank, or type quit: Miller Lite
- Added Miller Lite with 96.0 to your drink list.
Enter the beer you drank, or type quit: quit
You drank 2 beers.
Beers you drank:
- Budweiser
- Miller Lite
Total calories consumed: 241.0
In [7]:
beers = []
calories = []
your_beers = []
your_calories = []
file = 'NYC0-beer-calories.txt'
# TODO Write code here