Search code examples
pythonpython-2.7raw-input

"None" output after raw_input in Python 2.7 bug


This is a part of a text adventure that I am working on. It works fine until the user inputs any button to start, and then it prints "None". I was wondering if there was a simple way that I either am overlooking or do not know yet to prevent it from outputting "None".

def main():
    print "Welcome to my Text Adventure!"
    raw_input("Press any button to start!")

print main()

Solution

  • Function does not return anything (returns None) without explicit return statement.

    def main():
        print "Welcome to my Text Adventure!"
        return raw_input("Press any button to start!")