The below code is showing syntax error at line 21 where else: is given. Could anyone pls tell me what is wrong with it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The below code is showing syntax error at line 21 where else: is given. Could anyone pls tell me what is wrong with it?

def menu(): c='y' while c=='y': print("1.Add Record") print("2.Update Record") print("3.Delete Record") print("4.Display records") print("5.Exit") choice=int(input("Enter your choice")) if choice==1: addrecord() elif choice ==2: updatedata() elif choice==3: deldata() elif choice==4: fetchdata() elif choice==5: print("Exiting") break else: print ("Wrong Input") c=input("Do you want to continue or not,press y or n")

24th Jan 2022, 2:54 PM
Sam
Sam - avatar
2 Answers
+ 1
#Identation error: #Working code : def menu(): c='y' while c=='y': print("1.Add Record") print("2.Update Record") print("3.Delete Record") print("4.Display records") print("5.Exit") choice=int(input("Enter your choice")) if choice==1: addrecord() elif choice ==2: updatedata() elif choice==3: deldata() elif choice==4: fetchdata() elif choice==5: print("Exiting") break else: print ("Wrong Input") c=input("Do you want to continue or not,press y or n") menu()
24th Jan 2022, 3:01 PM
Jayakrishna 🇮🇳