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
Rodrigo Muñoz
Courses Plus Student 20,171 Pointsmultiply views 5/5: Task 1 is no longer passing
I have changed the response to multiply the two arguments and return their product. Looks like this:
from flask import Flask
app = Flask(__name__)
@app.route('/multiply')
@app.route('/multiply/<int:num1>/<int:num2>')
@app.route('/multiply/<float:num1>/<int:num2>')
@app.route('/multiply/<int:num1>/<float:num2>')
@app.route('/multiply/<float:num1>/<float:num2>')
def multiply(num1=5,num2=5):
return '{} * {} = {}.format(num1, num2, num1*num2)'
I'm getting: Task 1 is no longer passing as I've changed the response. Am I missing something?
4 Answers
Rodrigo Muñoz
Courses Plus Student 20,171 PointsFixed:
from flask import Flask
app = Flask(__name__)
@app.route('/multiply')
@app.route('/multiply/<int:num1>/<int:num2>')
@app.route('/multiply/<float:num1>/<int:num2>')
@app.route('/multiply/<int:num1>/<float:num2>')
@app.route('/multiply/<float:num1>/<float:num2>')
def multiply(num1=5,num2=5):
return str(num1*num2)
Chris Freeman
Treehouse Moderator 68,468 PointsIf you're still interested, when a challenge says "Task 1 is no longer working" it usually means a syntax error was introduced when working on a subsequent task. The other reason is a real bug was introduced. This case seems it's a bug.
In your code, I noticed that the format() is inside the quotation marks. You have:
def multiply(num1=5,num2=5):
return '{} * {} = {}.format(num1, num2, num1*num2)'
verses:
def multiply(num1=5,num2=5):
return '{} * {} = {}'.format(num1, num2, num1*num2) # <-- moved closing quote
Caleb Kleveter
Treehouse Moderator 37,862 PointsWhen you do a code challenge you need to leave all previous code that you have written, If the instructions say anything about changing code you write, then the new code goes below the original code. Hope that answers your question!
Rodrigo Muñoz
Courses Plus Student 20,171 PointsThanks Caleb, I've solved the problem.
Mike Siwik
Front End Web Development Techdegree Student 14,814 Pointsfrom flask import Flask
app = Flask(__name__)
@app.route('/multiply')
@app.route('/multiply/<num1>/<num2>')
@app.route('/multiply/<int:num1>/<int:num2>')
@app.route('/multiply/<float:num1>/<float:num2>')
@app.route('/multiply/<int:num1>/<float:num2>')
@app.route('/multiply/<float:num1>/<int:num2>')
def multiply(num1=5, num2=5):
return '{}'.format(num1*num2)
return str(num1*num2)
This worked for me
Chris Freeman
Treehouse Moderator 68,468 PointsChris Freeman
Treehouse Moderator 68,468 PointsChanged to Answer. Marked as best answer.