It’s my day 1 of learning python. so it’s a noob question for many of you. See the following code:
#!/usr/bin/env python
import sys
def hello(name):
name = name + '!!!!'
print 'hello', name
def main():
print hello(sys.argv[1])
if __name__ == '__main__':
main()
when I run it
$ ./Python-1.py alice
hello alice!!!!
None
Now, I have trouble understanding where this "None" came from?
Count the number of
printstatements in your code. You’ll see that you’re printing"hello alice!!!"in thehellofunction, and printing the result of thehellofunction. Because thehellofunction doesn’t return a value (which you’d do with thereturnstatement), it ends up returning the objectNone. Yourprintinside themainfunction ends up printingNone.