Python Python Basics Types and Branching String Methods

salman khan
salman khan
1,283 Points

error!!!!!!!

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
Steven Parker
171,342 Points

By 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
salman khan
1,283 Points

thank you,Steven Parker.