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 trialTrenton Spears
Python Development Techdegree Graduate 16,969 PointsTechnical Interview Prep: Python Basics > How Do You Like Them Apples
Bummer: Uh oh, I didn't get the correct value returned. It should have been 59. Instead, it was 18
#Create a function called "mathy"
# that calls a string and two numbers
def mathy(str, num1, num2):
#Add two numbers and return the sum
return num1 + num2
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsHey Trenton Spears, the challenge will call your function with string
equal to the one of the four operator names. You will need to check the value of string
to decide the math operator to use. An if/elif/else
statement works well here.
Also, str
is a built-in object type. Using str
as a variable name should be avoided if possible.
Post back if you need more help. Good luck!!!
Trenton Spears
Python Development Techdegree Graduate 16,969 PointsTrenton Spears
Python Development Techdegree Graduate 16,969 PointsHey, Chris Freeman thanks for reaching out, unfortunately, I'm still stuck. Is there either another way you could break down your guidance or, a video section within a particular course you maybe could recommend?
Trenton Spears
Python Development Techdegree Graduate 16,969 PointsTrenton Spears
Python Development Techdegree Graduate 16,969 PointsThere's gotta be something wrong with my
if/elif/else
statement, am I right?..Bummer: Uh oh, I didn't get the correct value returned. It should have been 50. Instead, it was 150
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 PointsYour answer should be in the form
Trenton Spears
Python Development Techdegree Graduate 16,969 PointsTrenton Spears
Python Development Techdegree Graduate 16,969 PointsIs there a specific lesson video or section on the platform you can point me to so that I can refresh myself on the exercise requirements?
Bummer: Uh oh, I didn't get the correct value returned. It should have been 50. Instead, it was 150
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 PointsThe line
x = num1 + num2
overwrites the parameterx
. Move this line to theelse
block. Better yet, there isnβt a need to assign to x. You can simplyreturn num1 + num2
Be sure to include all four operating names.
Trenton Spears
Python Development Techdegree Graduate 16,969 PointsTrenton Spears
Python Development Techdegree Graduate 16,969 PointsGot it!
Thanks again Chris