# MilkSurveyBot.py # # Description: Milk Survey Bot that asks the user whether s/he has tried almond, # coconut, cow, goat, hemp, oat, rice, and/or soy milk. # Then it prints the number of different kinds of milk the user # has tried. # # Author: AL # Date: Feb. 2024 # Create a list of all types of milk milks = ["almond", "coconut", "cow", "goat", "hemp", "oat", "rice", "soy"] # Initialize the accumulator variable "milkCount" to 0 milkCount = 0 # Initialize the accumulator variable "whichMilk" to an empty list whichMilk = [] # Print the question to the user print("How many different types of milk have you tried?") print("For example, have you tried ...") # Display one type of milk at a time ... for eachMilkType in milks: # ... and read the user's answer answer = input("... " + eachMilkType + " milk? (y/n): ") # If the user has tried this type of milk ... if answer.lower() == "y": # ... accumulate the name of the milk in the accumulator variable list whichMilk.append(eachMilkType) # and accumulate the # of milk type tried in the accumulator variable milkCount += 1 # Print the result of this milk survey to the user # BONUS Part 1 print(f"Wow! You have tried {milkCount} different kinds of milk \ (out of {len(milks)}).") # BONUS Part 2 - print a list of all milk types the user has tried! print("BONUS PART - You tried:") for eachMilkType in whichMilk: print(eachMilkType)