Skip to content

Python newbie weird output #21448

Discussion options

You must be logged in to vote
Hikari334:
    print(factorial())

This line is the reason: It writes the return value of the factorial() function to standard output. There is no explicit return statement in the function, so the return value is None.

There are a number of other issues with the factorial() function:

  • It uses the global variable number instead of a parameter.

  • Don’t use the end parameter to print() for data. Instead better return the calculated value and format the result.

  • If the parameter number is invalid, the function should raise an error instead of just writing a message.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants