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")
2 Réponses
+ 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")
+ 1
Got it. Thank you Simba