formatter = "%r %r %r %r" print formatter % (1, 2, 3, 4) print formatter % ("one", "two", "three", "four") print formatter % (True, False, False, True) #%r can even format characters that are really programming code, but it can print them as a string #but it also outputs them as a string, in quotes, so its output can be used by a program as well print formatter % (formatter, formatter, formatter, formatter) #%r here even demonstrates that it can tell the right kind of quotes to output #so that it doesn't get confused by the single quote (apostrophe) used in the middle of the third line: print formatter % ( "I had this thing", "That you could type up right.", "But it didn't sing.", "So I said goodnight." )
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question