Python Forum

Full Version: Printing one thing from a list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to see if I can make something in Python that can make a sentence. The only way I can think to do this is by making the process go, "If I choose an 'I', than after that I should put (insert multiple things that would make sense to go after 'I' here)". Problem is I'm a noob at Python knowing next to nothing about how to use it. The most I could do is assign values and make it print out a math equation. I'm wondering if I can make it go like this:

print([One item from list A] [Item from list corresponding to the word from list A] [Item corresponding to that list]...) ect ect until a sentence is made.

Pry not the best way to do this but I thought it'd be a nice project.
I would do it like MadLibs. A sentence with blanks in it, each blank having a part of speech (noun, verb, adjective). Then you have a list of nouns, a list of verbs, and a list of adjectives. Use random.choice to pick random words of the right parts of speech to fill in the blanks in the sentence.