Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Print says the whole variable

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)")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading