Hey I would like to declare a String in Python which is a long text (with line breaks and paragraphs). Is this possible? If I just copy-paste de text into quotations Python only recognizes the first line and I have to manually remove all the line breaks if I want the entire text. If this is possible would it still be possible if the text have quotations ("")?
Use triple quotes : mytext = """Some text Some more text etc... """ Note that while not commonly used, triple single quotes also work although triple-double-quotes are preferred (as long as your string doesn't contain triple-double-quotes). Phew, that's a mouthful.
To convert an integer to string in Python, use the str() function. This function takes any data type and converts it into a string, including integers. Use the syntax print(str(INT)) to return the int as a str , or string.
Use """ (double quote) or ''' (single quote) for multiline string or use \ for seperating them. NOTE: """ and ''' should be used with care otherwise it may print too many spaces in between two lines.
Use triple quotes :
mytext = """Some text
Some more text
etc...
"""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With