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 trialDominique Gaines
505 Pointsformatting.
name = 'dom' subject = 'Treehouse loves {} '.format(name)
In Python 2 : subject = 'Treehouse loves %s' %dom
name = 'dom'
subject = 'Treehouse loves {} '.format(dom)
3 Answers
Andrew Mlamba
15,642 PointsThe .format() method in your code is taking the wrong argument.Change it your name variable
name = 'dom'
subject = 'Treehouse loves {} '.format(dom) # <-- here
Ronald Tse
5,798 Pointsdom is the value ⇒ you should add " ".
If you don't want to use " " (the value), you should directly use the variable name, name
Below 2 codes are the same, make sure you understand the difference between value & variable!!
name = 'dom'
subject = 'Treehouse loves {} '.format(name)
subject = 'Treehouse loves {} '.format('dom')
Hope it helps!!!! Good luck!!
Alexander Davison
65,469 PointsDoes the variable dom
exist?
Simple answer: No.
Since you didn't put double/single quotes around the text, Python will look for a variable called dom
, which, of course doesn't exist.
However, even if you put double quotes around it, the challenge won't expect it. This is because the challenge asked ot you format the name
variable, which has you name assigned to it.
Look here:
name = 'dom'
subject = 'Treehouse loves {}'.format(name)
I hope this helps
~Alex