Merge Week 1 #1

Merged
Kenwood merged 10 commits from week-1 into master 2021-01-08 21:14:34 -05:00
1 changed files with 5 additions and 1 deletions
Showing only changes of commit 0b457c6c88 - Show all commits

View File

@ -2,8 +2,12 @@
# Construct a mad lib # Construct a mad lib
class mad_lib: class mad_lib:
# Initalize a constructor for python mad lib
def __init__(self, lib): def __init__(self, lib):
# lib is a value passed in during the construction of this class
self.text = lib self.text = lib
# Replace %text% with user input
self.text = self.text.replace('%first_name%', self.first_name()) self.text = self.text.replace('%first_name%', self.first_name())
self.text = self.text.replace('%location%', self.location()) self.text = self.text.replace('%location%', self.location())
self.text = self.text.replace('%whole_number%', self.whole_number()) self.text = self.text.replace('%whole_number%', self.whole_number())
@ -30,4 +34,4 @@ class mad_lib:
# Construct a mad lib # Construct a mad lib
md = mad_lib('%first_name% went to %location% to buy %whole_number% different types of %plural_noun%') md = mad_lib('%first_name% went to %location% to buy %whole_number% different types of %plural_noun%')
print(md.text) print(md.text)