User:Laura Macchini/prototyping/marryme

From XPUB & Lens-Based wiki
< User:Laura Macchini
Revision as of 11:12, 20 October 2011 by Laura Macchini (talk | contribs) (Created page with "== The Code == <source lang="python"> #!/usr/bin/python beginning = " Soldier, soldier, will you marry me \n With your musket, fife and drum? \n Oh how can I marry such a pretty...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Code

#!/usr/bin/python

beginning = " Soldier, soldier, will you marry me \n With your musket, fife and drum? \n Oh how can I marry such a pretty little girl"
items = ["coat","shoes","hat"]
ending = "When I've a wife and child at home?"
midlist = ["it","them"]
middle1 = "Off to the tailor she did go \n As fast as she could run \n She brought him back the finest that was there \n Now soldier, put "
middle2 = " on"

for x in range(0,3):
	print beginning
	print "When I have no "+items[x]+" to put on?"
	print
	if x != 2:
		print middle1+midlist[1]+middle2
	else:
		print middle1+midlist[0]+middle2
	print
print beginning
print ending

The Result

 Soldier, soldier, will you marry me 
 With your musket, fife and drum? 
 Oh how can I marry such a pretty little girl
When I have no coat to put on?

Off to the tailor she did go 
 As fast as she could run 
 She brought him back the finest that was there 
 Now soldier, put them on

 Soldier, soldier, will you marry me 
 With your musket, fife and drum? 
 Oh how can I marry such a pretty little girl
When I have no shoes to put on?

Off to the tailor she did go 
 As fast as she could run 
 She brought him back the finest that was there 
 Now soldier, put them on

 Soldier, soldier, will you marry me 
 With your musket, fife and drum? 
 Oh how can I marry such a pretty little girl
When I have no hat to put on?

Off to the tailor she did go 
 As fast as she could run 
 She brought him back the finest that was there 
 Now soldier, put it on

 Soldier, soldier, will you marry me 
 With your musket, fife and drum? 
 Oh how can I marry such a pretty little girl
When I've a wife and child at home?