Skip to content

Instantly share code, notes, and snippets.

@gabrielbissey
Created February 5, 2018 23:20
Show Gist options
  • Save gabrielbissey/3638dab6b310124c6335b0fd787935f1 to your computer and use it in GitHub Desktop.
Save gabrielbissey/3638dab6b310124c6335b0fd787935f1 to your computer and use it in GitHub Desktop.
Madlib processor
from random import randint
def random_verb():
random_num = randint(0, 1)
if random_num == 0:
return "run"
else:
return "kayak"
def random_noun():
random_num = randint(0,1)
if random_num == 0:
return "sofa"
else:
return "llama"
def process_madlib(string):
processed = ''
i = 0
while i != len(string):
next_character = string[i]
if next_character == 'N':
processed = processed + random_noun()
if next_character == 'V':
processed = processed + random_verb()
else:
processed = processed + next_character
i += 1
return processed
print process_madlib("N it feels good to V a gangster")
print process_madlib('Hello N, do you know how to V?')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment