-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmadlibs.py
23 lines (20 loc) · 1.23 KB
/
madlibs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# tutorial based on https://www.youtube.com/watch?v=8ext9G7xspg
# there are 3 ways to approach creating a string that says "blah blah ________" with a variable for the blank
# print("string" + variable)
# print("string {}".format(variable)
# print(f"string {variable}") F-String is nice and clean
print("Welcome to the MadLib game!")
# gather up variables in use, and run them first
adj = input("Adjective: ")
verb1 = input("Verb: ")
verb2 = input("Verb: ")
famous_person = input("Famous person: ")
# make a variable that contains a function, string, and another variable
# note the backslash acts as a line break in Python code, but doesn't show in the program as used by clients, it's just to help Devs
madlib = f"Computer programming is so {adj}! It makes me so excited all the time because \
I love to {verb1}. Stay hydrated and {verb2} like you are {famous_person}!"
print(madlib)
# end program
# if you copy all this text and drop it in a .py file in your VSCode you can run it in a terminal there for testing and tweaking
# don't forget to delete your old terminal data because that could generate strange errors that aren't related to this code
# packaging this code up so that it can run on a web page or a desktop is a whole other bit of work