Create your own version of the Mayoral Excuse Machine in Python that takes in a name and location, selects an excuse at random and prints an excuse("Sorry, Richard, I was late to City Hall to meet you, I had a very rough night and woke up sluggish")
Use the "excuse.csv" in the Github repository
Extra credit if you print the link to the story as well
In [23]:
import pandas as pd
import random
In [9]:
df = pd.read_csv('data/excuse.csv')
In [17]:
df['excuse']
Out[17]:
In [22]:
excuse_list=pd.Series.tolist(df['excuse'])
name_list = ['Leonardo', 'Donatello', 'Michelangelo', 'Raphael']
location_list = ['Kitchen', 'Bathroom', 'Livingroom', 'Closet']
In [34]:
def random_name():
return random.choice(name_list)
def random_location():
return random.choice(location_list)
def random_excuse():
return random.choice(excuse_list)
In [40]:
def mayoral_excuse_machine():
return "Sorry, " + random_name() + ", I was late to " + random_location() + " to meet you, " + random_excuse() + '.'
In [41]:
mayoral_excuse_machine()
Out[41]: