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

Python Python Basics Types and Branching String Methods

Why aren't there quotes surrounding 3?

In the video, the example "You just bought {} {}.".format(3, "fidget spinners") displays, "You just bought 3 fidget spinners." but why aren't there quotes surrounding the 3 when you format it? Maybe I missed something in a lesson, so that's why I'm unsure.

3 Answers

Steven Parker
Steven Parker
231,236 Points

Quotes go around literal strings, but not around literal numbers. The arguments to "format" can be either type, and are converted to strings automatically if needed.

robertdorgan
robertdorgan
5,944 Points

Integers or int do not require quotes. Quotes are used for strings.

Oh I actually tried this just messing around like str(42 + "eleven") i expected like the print function to be 42eleven, but instead it messes up, so instead you would do str({} {}.".format(42, "eleven:)

What i would like to knwo is what the heck is {} or .". or format( :F