0
votes

As the title says, is the print() function in python a void function?

I thought the print() function returns and prints to screen what is passed into it. Now that I think about it, it seems like it doesn't return anything and is indeed a void function. Can someone verify this for me please? Thanks in advance!

I've tried the following:

some_variable = print()

print(some_variable) None

3

3 Answers

1
votes

It does not return a value, which is the same as returning None. You won't find it explicitly in the documentation as functions returning None simply omit documenting the return value.

0
votes

It doesn't return any value; returns None. you can consider as void

please referReturn Value from print()

0
votes

There are no void functions in Python. Functions without explicit return returns None, an object of type NoneType. Try print(type(None)) or print(None.__class__)

print prints to the text stream and doesn't return anything (returns None).

https://docs.python.org/3/library/functions.html#print