+ 4
Hi,how how to use " " " triple quatation in a string in Python 3,i cant grasp it's ideal usage
7 ответов
+ 4
To write a multiple of lines string without recieving an EOL (end of line) error, example:
string1 = """hello
world"""
print(string1)
>>output:
hello
world
+ 3
Vusumuzi Mabena
*wrong*
print("hello
world")
>>output:
EOL error while scanning
*right*
print("""hello
world""")
>>output:
hello
world
+ 3
I basically don't use it at all. Usually I prefer to spread strings like this:
print('Hello'
' world!')
Usually triple quotes come up with docstrings.
def f():
'''This function does:
blablabla
blablabla''"
# And now the actual code
+ 2
I really don't understand how to properly use this,can you please show me the how to write the multiple lined that produces erros ,and a right way to to right multiple lines using triple qoutes " " "
+ 1
Ya it's just an alternative method
It's up to us how we use it
0
""" it is generally used when you want to inspect your code on output screen"""
Unlike conventional comments these docstring comments retain throughout the program run
That's it!
0
Arnav Deshpande, Python doesn't require that you put your docstrings in triple quotes. Regular string literals work just as well!