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

I had a different answer for the ticket remaining solution.

I had a different answer for the ticket remaining solution.

My Ticket remaining solution was: print("There are {}".format(tickets_remaining), "tickets remaining.")

VS

The Video's ticket remaining solution print("There are {}tickets remaining.".format(tickets_remaining))

Is my solution incorrect, or just simply another way in creating the string?

1 Answer

Hi Auceanne!

This:

tickets_remaining = 5

print("There are {} tickets remaining.".format(tickets_remaining))

prints out:

There are 5 tickets remaining.

This:

tickets_remaining = 5

print("There are {}".format(tickets_remaining), " tickets remaining.") # notice the space before tickets

prints out:

('There are 5', ' tickets remaining.')

More info:

https://realpython.com/python-string-formatting/

https://www.datacamp.com/community/tutorials/python-string-format

BTW, I test. code like that here:

https://www.katacoda.com/courses/python/playground

I hope that helps.

Stay safe and happy coding!