-1

I am getting this invalid syntax for if selection == 1: under def mainmenu(): Do not understand why I am getting this error. Please help me figure this out. I completely doesnt make any sense to me why its there. contacts = {}

class person:

    def ___init__(self,first,last,number):
        self.first = first
        self.last = last
        self.number = number

    def get_info(self):
        print(first,last,number)

class friend(person):

    def __init__(self,email,bday):
        self.email = email
        self.bday = bday

    def get_info_friend(self):
        super().get_info()
        print(email,bday)

def add_a_contact():
    choice  = int(input("Contact type: \n\t 2: Person \nEnter an option here:"))
    first = input("Enter the first name:")
    last = input("Enter the last name:")
    number = input("Enther the number:")

    if choice == 1:
       email = input("Email Address is:")
       bday = input("Their bday is:")
       return Friend(email,bday,first,last,number)
     return person(first,last,number)

def add_contact_to_dict():
    contact = add_a_contact()
    contacts[contact.last_name] = contact

def lookup():
   last = input("What is their last name?:")
   if last in contacts:
        contact = contacts[last]
        print("Name&number: ", contact.first,contact.last,contact.number)
   if type(friend) is friend:
        print("Email and Bday is: ", contact.email,contact.bday)

def mainmenu():
   selection = 0
   temp = ""
   while selection != 3:
       print("Select an option: \n\t 1: Add \n\t 2: Lookup \n\t 3: Exit")
       selection = int(input("Enter an option:")
       if selection == 1:
            temp = add_contact_to_dict()
        elif selection == 2:
            lookup()
        elif selection == 3:
            pass
        else:
            print("Not a valid option")

 if __name__ == "__mainmenu__":
     mainmenu()
  • 5
    Well, you're missing a closing `)` on the line `selection = int(input("Enter an option:")` – xnx Dec 11 '14 at 02:16
  • Your indents are also incorrect. They need to be exactly the same on lines like `if selection == 1:` and `elif selection == 2:`. Also you should make it `if __name__ == "__main__":`, see here: http://stackoverflow.com/questions/419163/what-does-if-name-main-do – 101 Dec 11 '14 at 02:22
  • The indents are right in my original code its just it got a little messed up moving it on here but thank you I didnt even notice the ending ) this was beginning to frustrate me so much. – Brett Smitch Dec 11 '14 at 02:27

1 Answers1

0

So when you are asked for the input under selection, you need another bracket to for the "int" part. Hopefully, that should solve your issue.

Zizouz212
  • 4,908
  • 5
  • 42
  • 66