Python Python Basics Types and Branching If, Else and Elif

Daniel Taieb
Daniel Taieb
135 Points

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

diogorferreira
diogorferreira
13,264 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))
else: 
    print ("Get out of here")