User:Laura Macchini/prototyping/marryme: Difference between revisions

From XPUB & Lens-Based wiki
(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...")
 
Line 7: Line 7:
ending = "When I've a wife and child at home?"
ending = "When I've a wife and child at home?"
midlist = ["it","them"]
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 "
places = ["tailor","cobbler","hatter"]
middle2 = " on"
 
for x in range(0,3):
for x in range(0,3):
print beginning
print beginning
Line 15: Line 13:
print
print
if x != 2:
if x != 2:
print middle1+midlist[1]+middle2
print "Off to the "+places[x]+" she did go \n As fast as she could run \n She brought him back the finest that was there \n Now soldier, put "+midlist[1]+" on"
else:
else:
print middle1+midlist[0]+middle2
print "Off to the "+places[x]+" she did go \n As fast as she could run \n She brought him back the finest that was there \n Now soldier, put "+midlist[0]+" on"
print
print
print beginning
print beginning

Revision as of 13:22, 20 October 2011

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"]
places = ["tailor","cobbler","hatter"]
for x in range(0,3):
	print beginning
	print "When I have no "+items[x]+" to put on?"
	print
	if x != 2:
		print "Off to the "+places[x]+" she did go \n As fast as she could run \n She brought him back the finest that was there \n Now soldier, put "+midlist[1]+" on"
	else:
		print "Off to the "+places[x]+" she did go \n As fast as she could run \n She brought him back the finest that was there \n Now soldier, put "+midlist[0]+" on"
	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?