[Tutor] Python = {0}.format

abid saied abidsaied at gmail.com
Sun Aug 17 16:50:15 CEST 2014


Hi,

I’m in the process of teaching myself python. Can someone have a look at the text in red and explain please.

# String exercise 2

print("Quote Formatter")
print("This program displays a given quote in different formats")
print() # Why is this needed?
quote = input("Please enter a quote to format: ")
print(quote)
print(quote.upper())
print(quote.lower())
print(quote.capitalize())
print(quote.title())
replaceWord = input("Which word in the quote would you like to replace: ")
replaceWith = input("Please enter the word to replace with: ")
print("The original quote is: {0}".format(quote))
print("The new quote is:{0}".format(quote.replace(replaceWord,replaceWith)))
# Not sure what the {0}.format is doing

Thanks.

Abid 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140817/9b3a31e3/attachment.html>


More information about the Tutor mailing list