Print says the whole variable

Viewed 31

So I've been trying to make it so I can print out a long line so I can be able to have it look fancy but doesn't seem to be working like normal...

playerguess = input()
playerguess = int(playerguess)
days = 2
example = ("Looks like this storm won't stop for another ", days + playerguess, " we will have to wait")
print("-Captain Strand- \"", example, "\" (You can barely hear him but thats all you hear)")
1 Answers

For your example, you probably meant to use "".join(example), however, you may really want to template a multiline string and use .format() (which are both methods of the string)

TEMPLATE = """{header}
"Looks like this storm won't stop for another {days}, we will have to wait"
(You can barely hear him but thats all you hear)"""

TEMPLATE.format(
    header="-Captain Strand-",
    days=days + playerguess,
)
>>> print(TEMPLATE.format(
...     header="-Captain Strand-",
...     days=days + playerguess,
... ))
-Captain Strand-
"Looks like this storm won't stop for another 5, we will have to wait"
(You can barely hear him but thats all you hear)

originally

>>> example = ("Looks like this storm won't stop for another ", days + playerguess, " we will have to wait")
>>> example  # example is a tuple of strings
("Looks like this storm won't stop for another ", 5, ' we will have to wait')
>>> example = "".join(("Looks like this storm won't stop for another ", str(days + playerguess), " we will have to wait"))
>>> example  # example is a single string
"Looks like this storm won't stop for another 5 we will have to wait"
Related