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 (2015) Python Data Types Splitting and Joining

Manpreet Singh
Manpreet Singh
13,014 Points

format function is not working in python

flavor = ['chocolate','mint','strawberry']

"My favourite flavour : {}".format(", ".join(flavor))

Please help me to solve this

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Would it be comforting to know that it's working just fine? It's actually doing the join with the string just as expected. The problem here is that you're not displaying the result of the operation. So if I edit your code just slightly, you can see the results.

flavor = ['chocolate','mint','strawberry']

print("My favourite flavour : {}".format(", ".join(flavor)))

Alternatively, you could store the results of your operation in a variable and print that out. This will be needed in an upcoming challenge by the way.

flavor = ['chocolate','mint','strawberry']

results = "My favourite flavour : {}".format(", ".join(flavor))
print(results)

Remember that computers are actually pretty dumb. They won't do anything you don't tell them to do. So if you never tell them to show the results of an operation... they won't.

Hope this helps! :sparkles:

Manpreet Singh
Manpreet Singh
13,014 Points

Thanks for helping can you please do one more favour and tell me the best python editor in which i can write code

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Well, that's a matter of opinion. A lot of people use Pycharm, but I tend to use Visual Studio Code. It's really just personal preference :smiley: