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 trialtroy serr
Courses Plus Student 160 Pointsmaking strings
im trying to make a string using str.format and it says namerror what am i doing wrong?
str.format ("troy")
2 Answers
Daniel Bourke
3,870 PointsYou're very close!
I think the question is asking for a name variable.
So maybe something like:
name = "{}".format( )
Where your name would be an argument in the format function (in string form of course).
Daniel Bourke
3,870 PointsAlmost perfect!
Remember .format( ) will update { } with whatever is within ( ).
Example:
#name variable is updated to be Daniel
name = "{}".format("Daniel")
#example two
full_name = "{}{}".format("Daniel","Bourke")
Hope this helps!
troy serr
Courses Plus Student 160 Pointstroy serr
Courses Plus Student 160 PointsI Tried typing that it came up with this: NameError: name 'troy' is not defined"
name = "{troy}".format(troy)