Skip to content Skip to sidebar Skip to footer

After A Defined Statement Is Executed, "none" Is Printed Twice

When I run the following code and go through the whole request function and I answer n to the reqSecPass part, it prints goodbye followed by two lines that say None. How do I elimi

Solution 1:

You are printing the return values of your functions. Your functions all return None (the default return value when you don't use an explicit return statement).

Remove your print() statements from your function calls, so instead of:

print(another())
# ...
print(goodbye())
# ...
print(request())

just use

another()
# ...
goodbye()
# ...
request()

Alternatively, have your function return a string to print:

defgoodbye():
    return'Good Bye!'print(goodbye())

although is probably not worth using a function just to return a single string value.

Solution 2:

You are printing the value returned by functions that have no explicit return statement. The value returned from such a function is None by default. You are printing this value.

Try using a return statement sometimes instead of always printing, e.g. return 'Goodbye!'.

Post a Comment for "After A Defined Statement Is Executed, "none" Is Printed Twice"