Untitled

mail@pastecode.io avatar
unknown
plain_text
20 days ago
3.0 kB
7
Indexable
Never
Contacts = [["" for _ in range(3)] for _ in range(100)] # TO FIX - Question says to put column 1 contact name: last name, first name and column 2 - telephone number
CurrentSize = 0

#TO FIX (Optional) - Password check is not required
Continue = True
while Continue:
    print("Please enter a delete password, this will be require whenever you wish to clear your contact array.")
    Password = input()
    print("")
    print("Are you sure? This cannot be change once set.")
    print("Y/N")
    pchoice = input()
    if pchoice == "Y" or pchoice == "y":
        Continue = False

Continue = True
while Continue:
    print("")
    print("Please select an option:")
    print("1. Enter new contact details")
    print("2. Display all the contact details")
    print("3. Delete all the contact details")
    print("4. Exit the software")
    choice = input()

    while not choice.isdigit() or (int(choice) < 1 or int(choice) > 4):
        print("")
        print("Please select from the above.")
        choice = input()
        print("")
    
    if choice == "1":
        #TODO: allow up to max of 5 new contacts to array at one time
        #TODO: do not allow more than 100 contacts in total
        print("")
        print("Please enter the last name of the contact.")
        Contacts[CurrentSize][0] = input()
        print("")
        print("Please enter the first name of the contact.")
        Contacts[CurrentSize][1] = input()
        print("")
        print("Please enter his/her telephone number.")
        Contacts[CurrentSize][2] = input()
        print("")
        CurrentSize = CurrentSize + 1
        print("You know what you have done.")
        
    if choice == "2":
        if CurrentSize == 0:
            print("But there is no one here. ")
        if CurrentSize == 1:
            print("There is only 1 contact detail here.")
        if CurrentSize >= 2:
            print("There are currently ",(CurrentSize)," contact details here.")
        print(Contacts)
        
    if choice == "3":
        print("This will completely clear out the entire list of contacts, are you sure?")
        print("Y/N")
        dchoice = input()
        if dchoice == "Y" or dchoice == "y":
            print("")
            print("This action cannot be undo, are you really sure about it?")
            print("Y/N")
            d2choice = input()
            print("")
            if d2choice == "Y" or d2choice == "y":
                print("Please enter your delete password.")
                attempt = input()
                if attempt == Password:
                    Contacts = [["" for _ in range(3)] for _ in range(100)]
                    CurrentSize = 0
                    print("")
                    print("Deleted.")
                if not attempt == Password:
                    print("")
                    print("Incorrect password.")
        
    if choice == "4":
        print("I see, have a great day.")
        Continue = False
Leave a Comment