I have the following function:
>>> def rule(x):
... rule = bin(x)[2:].zfill(8)
... rule = str(rule)
... print rule
I am trying to convert rule into a string, but when I run the following command, here is what I get:
>>> type(rule(20))
00010100
<type 'NoneType'>
What is a NoneType variable and how can I convert this variable into a string?
Thanks,
you need to do:
All functions return
Noneimplicitly if noreturnstatement was encountered during execution of the function (as it is in your case).