I have created a function and I want to print its output to a file. But when I use the write method, it says you need to write a string. It’s type return none. What should I do?
(When I call the function, the output text in the console)
To write a number in the file, first make it a string type: str(123) .
the output of the function was not a number or a string, it was just what I printed with the print function
actually i tried to print inside the function it was then but i can not removing some quotes now
outputs are like this: 34, ‘+’, 56, ‘=’, 90
Is the function none returned?
no just type returns none
class
If the function returns nothing or returns None, you should write in the function, such as “return hello”.
Can’t I just say print(“hello”) do i have to use return
then you can’t print the function, write requires a string
print()
just displays output in the console. As such, print()
itself is a function that returns None
.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.