In [5]:
import pandas as pd
import random
url = 'https://raw.githubusercontent.com/ledeprogram/algorithms/gh-pages/class1/homework/data/excuse.csv'
df = pd.read_csv(url)
excuse_list = df['excuse'].tolist()
In [6]:
def excuse_to(name,location):
# step 01. get the name and location
data_stored = {'name':name,'location':location}
# step 02. prepare excuse
excuse = (random.choice(excuse_list))
# capitalize first letter of the sentence
excuse = excuse[0].capitalize() + excuse[1:]
data_stored['excuse'] = excuse
# step 03. Say your excuse
return "Sorry,{name}, I was late to {location} to meet you. {excuse}".format (**data_stored)
In [8]:
a = input("Who to apologize? ")
b = input ("Meeting location? ")
excuse_to(a,b)
Out[8]:
In [ ]: