Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Mikkel Bielefeldt
Mikkel Bielefeldt
3,227 Points

What's wrong with my code?

So I've been messing around with my own little program, testing to see if you're part of my family, and all of the sudden I've begun to get an Error in the 3rd line and I donate understand what the problem is. Thanks.

This program is testing if you're part of my family

name = input("What is your name? ") last_name = input("What is your last name, {}? ".format(name) full_name = name + " " + last_name

family = ["Mikkel Bielefeldt", "Lene Bielefeldt", "Lærke Bielefeldt", "Morten Bielefeldt", "Jette Bielefeldt", "Søren Bielefeldt", "Rikke Bielefeldt", "Jacob Risgaard", "Josefine Bielefeldt", "Isabella Bielefeldt", "Anne Bielefeldt", "Agnes Bielefeldt", "Janne Aagaard", "John Kirkegård", "Frederikke Aagaard", "Marie-Louise Aagaard", "Poul Aagaard", "Nikolaj Aagaard", "Else Aagaard", "Søren Aagaard"]

if full_name == "Mikkel Bielefeldt": print("Hey! How funny we're the same person") elif full_name == "Lene Bielefeldt": print("You're my mom!")

Checks to see if it's my mom, dad or sister

elif full_name == "Morten Bielefeldt": print("You're my dad!") elif full_name == "Lærke Bielefeldt": print("You're my sister!")

Checks to see if it's either of my grandparents

elif full_name == "Jette Bielefeldt": print("You're my grandmother") elif full_name == "Søren Bielefeldt": print("You're my grandfather") elif full_name == "Else Aagaard": print("You're my grandmother")
elif full_name == "Søren Aagaard": print("You're my grandfather")

Checks to see if it's my cousins

elif full_name == "Nikolaj Aagaard": print("You're my cousin") elif full_name == "Frederikke Aagaard": print("You're my cousin") elif full_name == "Isabella Bielefeldt": print("You're my cousin") elif full_name == "Josefine Bielefeldt": print("You're my cousin")

Checks to see if you're my aunts or uncles

Checks to see if you're my great grandma

elif full_name in family: print("You're part of my family {}!".format(name)) else: print("Maybe if you ask {}, you can be part of my family.".format(full_name)) x ''' Make something with y/n to check if they wanna be part of my family If no they you want to "break" If yes they need to go through a lot of stuff that they have to fill out E.g. phone number, adress, how old they're and so on. Maybe do something so that they cannot write numbers in their names and the opposite with phone numbers Get their middle name and if they don't have one then skip (if len(middle_name) <1:) and then print out nothing if it's less than 1 ''

1 Answer

Steven Parker
Steven Parker
229,732 Points

It looks like the issue is actually a missing parenthesis at the end of the second line:

last_name = input("What is your last name, {}? ".format(name)     # original line
last_name = input("What is your last name, {}? ".format(name))    # fixed

I was able to spot this in the unformatted code, but for future questions please always use "Markdown" formatting. There's a "cheat sheet" below, or you can watch this video on code formatting to learn how.