name=["Matin","Fereshteh","Ali","Zahra","Reza","Sara"] def my_list(): print("\n" + "-"*10 + " Your List " + "-"*10) count = 0 for i in name: print(str(count) + ") " + i) count = count + 1 def command(): command=["1. Add new name.","2. Insert new name.","3. Delete a name.","4. Sort list names.","5. Reverse elements.","6. counting of a value in list.","7. Find the index of a value."] print("\n" + "-"*10 + " Commands " + "-"*10 ) for i in command: print(i) print() c = int(input("select a command: ")) run_command(c) #return c def run_command(c): if (c == 1): name.append(str(input("enter a new name: "))) my_list(),command() elif (c == 2): name.insert(int(input("enter a position: ")),str(input("enter a value: "))) my_list(),command() elif (c == 3): name.pop(int(input("enter the name number: "))) my_list(),command() elif (c == 4): name.sort() my_list(),command() elif (c == 5): name.reverse() my_list(),command() elif (c == 6): print("Number of values: " + str(name.count("Matin"))) command() elif (c == 7): print("position of the element: " + str(name.index(str(input("enter a value: "))))) command() else: print("COMMAND ERROR!") my_list() command()