Functions - lists

example.py
def main():
    friends=["Jonathan","Mark","Danell","Joshua","Grant"]
    done = False
    while not done:
        print("Menu")
        print("D - Do Now")
        print("e1 - Example 1")
        print("e2 - Example 2")
        print("e3 - Example 3")
        print("Q - Quit")
        choice = input("Choice: ")
        if choice == "D":
            print("Do Now")
            print(friends)
        elif choice == "e1":
            e1(friends)
        elif choice == "e2":
            e2(friends)
            e1(friends)
        elif choice == "e3":
            e3(friends)
            e1(friends)
        elif choice == "Q":
            print("Exiting Game!")
            done = True
def e1(friends):
    for x in range(len(friends)):
        print(friends[x])
def e2(friends):
    name=input("What's his or her name? ")
    friends.append(name)
def e3(friends):
    e1(friends)
    fdelete=input("Which friend do you want to delete? ")
    friends.remove(fdelete)
main()

Last updated