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”)
In [1]:
import pandas as pd
In [2]:
df = pd.read_csv("excuse.csv")
In [3]:
df.head()
Out[3]:
In [4]:
import random
In [5]:
def random_excuse(line):
excuse = random.choice(line)
return excuse
random_excuse(df['excuse'])
Out[5]:
In [7]:
name = input("Enter your name: ")
In [8]:
location = input("Where are you headed? ")
In [10]:
print("Sorry", name, "I was late to", location, "because", random_excuse(df['excuse']))
In [ ]:
#Question: How to get the corresponding hyperlink if it's random?