0
Can u replace return with print
Return function in python
2 Respuestas
0
Return statement, returns value, which may not always used only for printing, it may used in calculation also... So there replacing print will lead to wrong results...
But
depends on your logic, depends on your code, you may thinking like:
Ex:
def a() :
return "hello"
print(a())
Can be written as same as :
def a() :
print("Hello")
a()
But they are not for same purpose so use return when need return, use print when you need print.
+ 2
Could you please come up with an example. A code where you would like to replace return with print.