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 trialSergio Niño
Full Stack JavaScript Techdegree Student 22,976 PointsUnpacking Dictionaries Unexpected
my_string = "Hi, my name is {} and I live in {}."
my_string.format("Sergio", "Colomobia")
'Hi, my name is Sergio and I live in Colomobia.'
in the video kenneth got an KeyError when he put their name and location between single quotes but instead I've put double quotes and apparently it works.. why?
2 Answers
Martin Cornejo Saavedra
18,132 PointsBy looking at some responses in stack overflow, simple quotes and double quotes are interchangeable (in python), they are a matter of taste. http://stackoverflow.com/questions/56011/single-quotes-vs-double-quotes-in-python
Justin Horner
Treehouse Guest TeacherHello Sergio,
As far as I know, there's no difference between single and double quotes in this case. I tried the example with single quotes without exception. Maybe there's something else he did in combination that caused the error.
I hope this helps.
Myles Marcus
1,233 PointsMyles Marcus
1,233 PointsThe difference is that in the first line of my_string....you didn't put anything between the {}...in the video he does and that is why his method got a KeyError