-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex8.py
More file actions
18 lines (17 loc) · 733 Bytes
/
ex8.py
File metadata and controls
18 lines (17 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Define formatter variable
formatter = "{} {} {} {}"
# Using the format function, send the listed 4 variables to the formatter
# variable replacing the {} with the listed variable in order then print
# the formatter variable with the listed variables.
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, False, True))
# In the single line below instead of replacing the {} with listed variables it
# prints the formatter variable itself four times keeping the {}
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
"Try your",
"Own text here",
"Maybe a poem",
"Or a song about fear"
))