-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmadlibs.py
More file actions
33 lines (25 loc) · 1 KB
/
madlibs.py
File metadata and controls
33 lines (25 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# filename: madlibs.py
# this is a comment
# the computer will ignore these lines
# comments are for humans/team mates
# how to make a multiline comment: use three single quotes
'''
Mary had a little lamb
His fleece was white as snow, yeah
And everywhere the child went
That little lamb was sure to go now
'''
# user greeting
print("Hello, welcome to mad libs!\n")
# to create a variable, use:
# variable_name = data
# input is a function that prompts a user for an input. it will save the input to the variable
animal = input("Name an animal: ")
something_white = input("Name an item that is white: ")
user_name = input("What's your name?")
# "\n" to create a new line
print("\n")
print("Thanks, here is your mad lib!\n")
# fstring: prints variables inside strings
print(f"{user_name} had a little {animal}\nHis fleece was white as {something_white}, yeah\nAnd everywhere the child went\nThat little {animal} was sure to go now")
# a string is anything, ANYTHING inside "quotation marks". a string is a type of data