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 trialsalman khan
1,283 Pointserror!!!!!!!
marks="{} got {} marks in maths" marks.format("wick","80") print(marks) EXPECTED OUTPUT:-wick got 80 marks in maths output:-{} got {} marks in maths
This code works perfectly on console,but does not work on code editor.
And \n does not give a new line in my console
1 Answer
Steven Parker
231,275 PointsBy putting the format and print on separate lines, the format is performed but the result is not saved anywhere, and then the print just outputs the original template string as-is.
Instead, combine them so you can print the result of the format:
print(marks.format("wick", "80"))
salman khan
1,283 Pointssalman khan
1,283 Pointsthank you,Steven Parker.