There is a difference in the way variable values are interpreted and assigned between the two code snippets.
In case of the first snippet, while assigning the value to "n", the new value of a is not used, rather the value of a from the previous iteration is used.
But, in case of the second snippet, the value of "a" is first updated and then used for the second statement.
Let's take an example:
For the first iteration where n is 1,
First Code Snippet: At the end of the iteration, the value of a will be 1 and value of n also will be 1. (For n = a+n, value of a is considered 0)
Second Code Snippet: At the end of the iteration, the value of a will be 1 and value of n will be 2. (For n = a+n, value of a is considered 1)
The key point to be noted about the Python Comma Operator is that, all the expressions to the right of the assignment operator are evaluated first before the assignments are actually made and this causes the difference in output between the two.