Can some please explain the use of three speech marks to make newlines in python and also explain what newlines are? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can some please explain the use of three speech marks to make newlines in python and also explain what newlines are?

Thanks for the help

25th Sep 2019, 4:27 PM
Kosti Scholey
Kosti Scholey - avatar
1 Answer
+ 4
Simply: New lines will make following text to be written in next line. print("Alpha\nBeta") #Output: Alpha Beta Newlines are represented as \n, because they are escape characters. Escape characters often have a special meanings. Strings created with pairs of 3* " or 3* " will automatically escape all escape characters, such as tabs and newlines. #Valid: """a b c""" #Equals 'a\nb\c' #Invalid: "a b c" #Valid: "a\nb\nc" Equals 'a\nb\nc' Deeper meaning of docstrings: You can use docstrings to make some description to a module, to a class or to a function, that will be displayed, when you execute help(name), when name is the name of the module/class/function whose documentation you want to display. Example: def useless_function(): """This function is does nothing.""" help(useless_function) #Output: ... useless_function() This function does nothing.
25th Sep 2019, 4:50 PM
Seb TheS
Seb TheS - avatar