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

Zhanar Khaibullina
Zhanar Khaibullina
8,841 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,423 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
8,841 Points

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

Zhanar Khaibullina
Zhanar Khaibullina
8,841 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
8,841 Points

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

Zhanar Khaibullina
Zhanar Khaibullina
8,841 Points

Chris Freeman, thank you very much!