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 Python Basics Types and Branching If, Else and Elif

Practicing if/else...

Hello I've tried to write a code. my intention is the program to identify if the person is a member of my family through yes/no answer and then print a different massage for each member of the family. what i accomplish this far:

identification = input("Are you a member of the Kats family?") if identification == "yes": print ("Hello, what is your first name?") else: print ("Get out of here")

i want the next step to be that each member of the family write his own name a get a unique massage, i have hard time trying do it, at first i've tried this code first_name = input("daniel" , "robert" , "david" , "sandra") but i get an error that input expected at most 1 arguments.

thanks for the help!

1 Answer

19,363 Points

Hi, the only problem with this is that when youre calling input, youre passing in the strings of the names e.g David, Sandra

  • To do this you just need to do like the indentification process, call input() and pass in the text or question e.g:
first_name = input("What is your name? / Who are you in the family?")
  • You can then use the first_name that they gave you and concatenate it or use format to create a custom message
  • You pass an argument into format() in this case name and then it will fill in the {}
identification = input("Are you a member of the Kats family?") 
if identification == "yes": 
    name = input("Hello, what is your first name?")
    print("Hello {}, how are you doing?".format(name))
    print ("Get out of here")