#prints a string: print "Mary had a little lamb." #prints a string with a format character and substitutes another string: print "Its fleece was white as %s." % 'snow' #prints a third string print "And everywhere that Mary went," #prints 10 copies of the same string, conjoined with no spaces inserted print "." * 10 #Defines several variables to be conjoined for printing later: end1 = "C" end2 = "h" end3 = "e" #used four times end4 = "s" end5 = "B" end5lc = "b" end6 = "u" end7 = "r" #used twice end8 = "g" #prints two conjoined combinations of strings, separated by a space #removing the comma separates the two combined strings by a line return instead #Is there a way to do it with no space at all? Oh yeah, don't make it a separate print statement... print end1 + end2 + end3*2 + end4 + end3, #re-uses end3 rather than having multiple variables with the same definition print end5 + end6 + end7 + end8 + end3 + end7 #re-prints the two combinations above with no separation: print end1 + end2 + end3*2 + end4 + end3 + end5lc + end6 + end7 + end8 + end3 + end7
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