HELP! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HELP!

I need help with this. Here are the instructions: a The Downdog Yoga Studio offers five types of classes, as shown in Table 6-1. Design a program that accepts a number representing a class and then displays the name of the class. b. Modify the Downdog Yoga Studio program so that numeric class requests can be entered continuously until a sentinel value is entered. Then display each class number, name, and a count of the number of requests for each class. classNum = [] classesName = [ "Yoga 1", "Yoga 2", "Children's Yoga", "Prenatal Yoga", "Senior Yoga", "Quit"] userInput = input index = classesName.index while index in classesName: if userInput == "1": userInput = input("Enter a class number or Quit: ") print("Yoga 1") elif userInput == "2": print("Yoga 2") elif userInput == "3": print("Children's Yoga") elif userInput == "4": print("Prenatal Yoga") elif userInput == "5": print("Senior Yoga") elif userInput == Quit: break print("Quit")

25th Apr 2020, 1:42 AM
Christian Sandoval
Christian Sandoval - avatar
1 Answer
0
names = ["Yoga 1","Yoga 2","Children's Yoga","Prenatal Yoga","Senior Yoga"] count = [0 for name in names] print("\nDOWNDOG YOGA STUDIO\n\nlist of available class:") for index, name in enumerate(names): print(" %i: %s" % (index+1,name)) print() while True: try: index = int(input("Enter a class index, or 0 to quit: ")) except: index = -1 if not index: break if index < 0 or len(names) < index: print("Invalid value...") continue index -= 1 count[index] += 1 name = names[index] print("Selected class name:",name) print("\nCount summary of selected classes:") for index, name in enumerate(names): print(" %i: %s => %i" % (index+1,name,count[index])) print()
25th Apr 2020, 11:20 PM
visph
visph - avatar