0

Python Core Q.43.2. I solved this way & it gave points. But the expected method shld be different I thnk. Pl Suggest

https://www.sololearn.com/learning/1073 coffee = ["Café Latte", "Caffe Americano", "Espresso", "Cappuccino", "Macchiato"] number = int(input()) length = len(coffee) try: for i,val in enumerate(coffee): if i==number or number>=length: print(coffee[number]) except: print("Invalid number") finally: print( "Have a good day")

16th Sep 2021, 10:49 AM
Suramuthu R
Suramuthu R - avatar
2 odpowiedzi
+ 1
#Try this coffee = ["Café Latte", "Caffe Americano", "Espresso", "Cappuccino", "Macchiato"] choice = int(input()) try: print(coffee[choice]) except: print("Invalid number") finally: print("Have a good day")
16th Sep 2021, 11:03 AM
Simba
Simba - avatar
+ 1
Got it. Thank you Simba
16th Sep 2021, 11:39 AM
Suramuthu R
Suramuthu R - avatar