I am new to Python and trying to create a user interface with options to insert, delete and update data. THe data will be manipulated in a text file. I wanted to accept option from user and call respective function to do the activity. One alternative that I found was to declare Dictionary The whole code is :
print("Select options from below")
dict_options = {'1' : 'Insert',
'2' : 'Update',
'3' : 'Delete',
'4' : 'Display_number_of_records',
'5' : 'Display_all_records',
'6' : 'Exit'}
for key in dict_options.keys():
value = dict_options.get(key)
print(str(key) + ". " + value)
option = input("Enter an option : ")
while (option != '6'):
value = dict_options.get(option)
dict_options[option]()
option = input("Enter an option : ")
def Insert():
print("Insert a record")
return`enter code here`
When I execute, it gives me an error:
TypeError: 'str' object is not callable at dict_options[option]()