+ 2
How to use the 2nd argument of print( ) in Python?
Actually I've found in some previous lessons abt using the 2nd arg for the print() func, maybe in some cmnts of the lessons, but now I can't recall or find the trick.. đ! I can recall that using the 2nd arg, one can chng the newline for each new output! So can anybody help on this kindly?
3 Answers
+ 8
Syntax:
print(object(s), sep=separator, end=end, file=file, flush=flush)
Parameters:
object(s) Any object, and as many as you like. Will be converted to string before printed
sep='separator' Optional. Specify how to separate the objects, if there is more than one. Default is ' '
end='end' Optional. Specify what to print at the end. Default is '\n' (line feed)
file Optional. An object with a write method. Default is sys.stdout
flush Optional. A Boolean, specifying if the output is flushed (True) or buffered (False). Default is False
+ 4
Hi, Himubab Cryptic !
When you donât remember, start try using help. In your case:
help(print)
It gives often a lot of usful information about what you are looking for.
+ 2
Thanks a lot bros!