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 trialJakub Stanio
6,378 PointsView Args Through URL
I kinda can't get to finish the 2nd task here: " Update the response from hello() to say "Hello {name}", replacing {name} with the passed-in name. " I have replaced the return as in the description but I am facing an error that the 1st task is not passing anymore. Any hints, please :) P.S.How do you paste nice formatted code?
from flask import Flask
app = Flask(__name__)
@app.route('/')
@app.route('/<name>')
def hello(name):
return 'Hello {name}'.format(name)
[MOD: Added ```python formatting -cf]
2 Answers
Chris Freeman
Treehouse Moderator 68,460 PointsWhen using named format fields, the arguments to format()
need to be keyword/argument pairs:
'Hello {name}'.format(name=name)
Post back if you have more questions. Good Luck!
Jakub Stanio
6,378 PointsI see, It makes sense now. Thanks a lot Chris :)