0

I am trying to understand how this comma separated solution works and how it is called, example:

b, c=0, 5
print(b,c)

>>0 5
  1. Why is variable 'b' value 0?
  2. Why is variable 'c' value 5?
The Thonnu
  • 3,578
  • 2
  • 8
  • 30
Fromi
  • 21
  • 1

1 Answers1

1

Comma separated values are interpreted as tuple, which can be unpacked:

t = 0,5 # sames as t = (0,5)
print(type(t))
a,b = t
print(a,b)

Out:

<class 'tuple'>
0 5
Maurice Meyer
  • 17,279
  • 4
  • 30
  • 47