-1

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()
falsetru
  • 357,413
  • 63
  • 732
  • 636

2 Answers2

2

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!")
falsetru
  • 357,413
  • 63
  • 732
  • 636
2

As you are printing the return value by main() function, so you are supposed to return something. But you are not doing so, which results in returning "nothing", which will print "None" on the console.

Try this

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

print main()
falsetru
  • 357,413
  • 63
  • 732
  • 636