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 trialDaniel Taieb
135 PointsPracticing 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
diogorferreira
19,363 PointsHi, 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))
else:
print ("Get out of here")