On 03/11/2013 03:18, Byron Ruffin wrote:
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()


Look very carefully at your assignment to y in wordList and you'll eventually answer your own question.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to