return print(char)
This will first print the value of char
(as in print(char)
) and then try to return the return value of the print function. But since the print function always returns None
—it only prints the value, it does not return it—your function will always return None
causing the error when trying to concatenate None
with a string.
To fix this, simply don’t print the character but just return it:
return char
solved Why do I get this error in Python?