I like to browse stackovorflow for gems of python code. I came across this tidbit yesterday, and it has me baffled.
Can someone explain how the following code works, what sort of code it is, and where I can find more information on using it?
I have tried searching for this sort of thing, but not knowing what sort of animal it is, the searches have returned nothing useful.
# Fibonacci Series
n = 1000
a, b=0, 1
while a<n:
print(a,end=" ")
a, b=b, a+b
print()
The lines that have me baffled are "a, b=0, 1" and "a, b=b, a+b"
They seem to be a format for some sort of default data type, but the type() command chokes and dies on it. Tampering with the structure can send it into an endless loop or cause the program to crash. Ditto with trying to split the parts up into separate lines, or replacing the commas with semi-colons.
Is it some form of python comprehension?
I love this stuff! Thanks for any insight you can offer.