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 trialZhanar Khaibullina
8,841 PointsPlease 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
Treehouse Moderator 68,423 PointsIf 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
8,841 PointsI 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!!
Miguel de Luis Espinosa
41,279 PointsOK,
The last line is OK
But
- 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.
- Then you have this variable "product" (same name as the function), that changes its value 3 times, but you never use
Zhanar Khaibullina
8,841 PointsMiguel de Luis Espinosa, thank you ver much!!!
Zhanar Khaibullina
8,841 PointsChris Freeman, thank you very much!
Zhanar Khaibullina
8,841 PointsYeah it works!!!!!!!!!
Zhanar Khaibullina
8,841 PointsZhanar Khaibullina
8,841 PointsOh! And I also have deleted the def function, so now it works!