Sep-01-2020, 03:44 PM
What is it you don't understand? That the numbers printed count down from 4 instead of 3, or that they all appear on the same line?
The numbers start at 4 and count down to 1 because you are printing n+1, not n. The value for n starts at 3 and it ends at 0, so the output starts at 3+1 and ends at 0+1. nilamo covers this very well.
The numbers are all printed on the same line because you replaced the "end" string. Normally the print command end = '\n' which is a new line, but you replaced this with a space. So when you print it just prints the value of n+1 and a space instead of the value of n+1 and a newline character.
The numbers start at 4 and count down to 1 because you are printing n+1, not n. The value for n starts at 3 and it ends at 0, so the output starts at 3+1 and ends at 0+1. nilamo covers this very well.
The numbers are all printed on the same line because you replaced the "end" string. Normally the print command end = '\n' which is a new line, but you replaced this with a space. So when you print it just prints the value of n+1 and a space instead of the value of n+1 and a newline character.