Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Types and Branching String Methods

Alan T.
Alan T.
4,784 Points

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
216,148 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