I made a simple algorithm that solved Fibonacci in 2 logical operations inside the loop. I decided to look for a better way and found a version that does in only 1 calculation in of the loop. It worked perfectly, but when I went to understand the logic appeared a problem.
The code that generates the correct sequence is as follows:
N = int(input())
x, b, a = 0, 1, 0
while x < N:
print('{}'.format(a), end=' ')
a, b = b, a + b
x += 1
So I tried to decompose the logic a, b = b, a + b
and the results began to give problems.
For example: Both
a = b
b = a + b
as
b = a + b
a = b
outputs a completely out of order sequence.
I ask: What is the error in changing the logic in these cases since I kept the same logical operations although in different lines? Is there any difference in being on the same line or in separate lines?