Yes i realize this is the fibonacci sequence and i understand the math im just having trouble understanding the line in red what does it equate to in laymans terms?
Thanks in advance :D

a,b=0,1
while b < 100:
  print b
  a,b=b,a+b

It's setting a equal to b, and b equal to a+b.

Achieved by this as well:

a = 0
b = 1
while b < 100:
print b
a = b
b=a+b

They just used some short hand statements.

This :

num1,num2 = 12,72

Is the same thing as :

num1 = 12
num2 = 72

Oh thanks :D

Hmm it spits out doubles when i do that instead of the fibonacci sequence any ideas?

Traditional way to do this is by temporary variable, because we need the old value of b in two formulas on the right side. Let's call the temporary variable new_b:

a,b=0,1
while b < 100:
  print b
  new_b = a + b
  a = b
  b = new_b

alternatively you can become clever and deside that it does not matter to destroy old value of b as the new value is a+b and the old b is a+b-a:

a,b=0,1
while b < 100:
  print b
  b = a + b
  a = b - a

Best way of course is the original Pythonic double assignment, where right hand values have the old variable values before the assignments.

Thanks for clearing that up and all the help guys :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.