Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

Zhanar Khaibullina
Zhanar Khaibullina
4,953 Points

Please help me with my code!!!

Hello! My problem is that I wrote code in the Work Space and I think my code is correct somehow, but at the same time it's not. Could you tell me what is the mistake in my code

def product(written_name, written_age, written_country):

    product = input("Hello, my name is: ")
    product = input("My age is: ")
    product = input("I came from: ") 

    print("Hi, my name's {}. I'm {}y.o and I'm from {}.".format(written_name, written_age, written_country))

5 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,166 Points

If you want to use the input function to fill in the fields of the print statement, make the following changes:

  • instead of assigning to product, replace "product" with each of the format argument names: written_name, written_age, written_country
  • since all values will come from inputs, no function parameters are needed. Use nothing between the parens
def product():

    written_name = input("Hello, my name is: ")
    written_age = input("My age is: ")
    written_country = input("I came from: ") 

    print("Hi, my name's {}. I'm {}y.o and I'm from {}.".format(written_name, written_age, written_country))

Post back if you need more help. Good luck!!!

Zhanar Khaibullina
Zhanar Khaibullina
4,953 Points

Oh! And I also have deleted the def function, so now it works!

Zhanar Khaibullina
Zhanar Khaibullina
4,953 Points

I want it to be like: so that the thing in a line 5 would output and the those gaps would be filled in by a input function, sorry for my bad English, thank you for your attention!!

OK,

The last line is OK

But

  1. You have this function "product" that takes 3 attributes: written_name, written_age, written_country

Where do you get the values for these 3 attributes? Nowhere.

  1. Then you have this variable "product" (same name as the function), that changes its value 3 times, but you never use
Zhanar Khaibullina
Zhanar Khaibullina
4,953 Points

Miguel de Luis Espinosa, thank you ver much!!!

Zhanar Khaibullina
Zhanar Khaibullina
4,953 Points

Chris Freeman, thank you very much!