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 trialZane MOODY
687 Pointsproduct_idea is a string. This statement is outputting and confused me. What makes product_idea a string in this?
I do not see it in the file where it is considered a string, so how does my function read it as a string? Thank you.
def suggest(product_idea):
return product_idea + "inator"
Steven Barkley
8,924 PointsWhile I haven't completed this assignment personal.... I'll try to clarify the general idea.
At the line where the suggest function is called the value it contains say : x=15 x="Some string" y = suggest(x)
is passed into the function def , because python is a "Dynamically typed language" values can be reassigned
In this case : y = "Some stringinator"
1 Answer
Steven Parker
231,248 PointsThe code that calls the "suggest" function and passes in the string for "product_idea" is part of the challenge validation system and is not shown here. That's why the instructions tell you that a string will be passed to it.
Zane MOODY
687 PointsThanks Steven, I just couldn't wrap my head as to why it was telling me. Appreciate the clarification.
Zane MOODY
687 PointsZane MOODY
687 Pointsto clarify I did complete this assignment. I had to look through the forums sadly, because I thought I had to assign the product idea to be a string by using the "try" and assigning the user's input for product_idea to have my "if statement" check the string to be less than 3 (using the len function).
I just feel confused because I don't see product_idea being assigned as a string in the code given. Could someone clariy why or how the return knows it is a string?