I'm looking at this fibonacci sequence program from python
#!/usr/bin/python3
# simple fibonacci series
# the sum of two elements defines the next set
a, b = 0, 1
while b < 50:
print(b)
a, b = b, a + b
print("Done")
The resulting output looks like this: 1, 1, 2 ,3 ,5 ,8 ,13 ,21, 34, Done
I'm slightly confused by the syntax of a, b = b, a + b
What's an equivalent version of this that is more expanded out?
EDIT ANSWER
Okay after reading up on things, below is one equivalent way, with a c temporary placeholder to grab original a
#!/usr/bin/python3
# simple fibonacci series
# the sum of two elements defines the next set
a = 0
b = 1
c = 0
while b < 50:
print(b)
c = a
a = b
b = a + c
print("Done")
More ways here: Is there a standardized method to swap two variables in Python? , including tuples, xor, and temp variable (like here)