[Tutor] space between words printed
Byron Ruffin
byron.ruffin at g.austincc.edu
Sun Nov 3 04:18:01 CET 2013
The output generates a sentence made up of words chosen randomly from
lists. I am having trouble getting a space between each of the words.
Should I be thinking about .split? Here is the code (ignore indent errors
as it was copied and pasted) Thank you:
import random
def wordList():
adj1 = ["Big", "Small", "Early", "Late", "Red",
"Tall", "Short"]
subj = ["politician", "man", "woman", "whale", "company",
"child", "soldier"]
obj = ["budget", "money", "box", "gift", "gun",
"tank", "drone"]
adj2 = ["hot", "crazy", "stupid", "fast", "worthless",
"awesome", "dirty"]
verb = ["spends", "shoots", "evades", "pursues", "subverts",
"passes", "flirts"]
y = adj1[generate()], subj[generate()] + obj[generate()] +
adj2[generate()] + verb[generate()]
return y
def generate():
random0_6 = random.randint(0, 6)
return random0_6
def main():
print (wordList(), ".", sep="")
main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131102/845f645c/attachment-0001.html>
More information about the Tutor
mailing list