Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! python3
- # madlibs.py
- import shelve, sys
- adjective = input('Enter an adjective:')
- noun = input('Enter a noun:')
- verb = input('Enter a verb:')
- secondnoun = input('Enter a noun:')
- textfile = open('C:\\MadLibs\\Text.txt', 'r')
- textfile = textfile.read()
- textfile = textfile.split()
- def change(textfile):
- nouncount = 0
- for word in enumerate(textfile):
- if word == 'ADJECTIVE':
- word = adjective
- elif word == 'NOUN':
- if word == 0:
- nouncount += 1
- word = noun
- else:
- word = secondnoun
- elif word == 'VERB.':
- word = verb
- result = change(textfile)
- print(result)
- result = ' '.join(result)
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement