Hi Tutor,

[a,b,c] = [1,2]
this will give
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 2 values to unpack

But is there any chance, if there are 3 values on left hand side and 2
values on right side, to add an empty value to the left side dynamically?

there can be multiple elements to unpack depending on what is expected on
left side.
Like in methods there can be optional parameters, if the values is not
passed, optional values will take what is been declared.

def optal(a,b,c=''):

"""

c - is option

"""

​Thanks,
Sunil. G
​
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to