+ 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")
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()