string.format()
Write a program to use string.format() method to format the following three variables as per the expected output
Given:
totalMoney = 1000 quantity = 3 price = 450
Expected Output:
I have 1000 dollars so I can buy 3 football for 450.00 dollars.
Solution:
quantity = 3 totalMoney = 1000 price = 450 statement1 = "I have {1} dollars so I can buy {0} football for {2:.2f} dollars." print(statement1.format(quantity, totalMoney, price))
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer