This is the presentation associated with the python Tuple Unpacking video.
[dflip id=”3629″ ][/dflip]
Python Tuple Unpacking Video Question
This is the question that was asked in the python tuple unpacking video:
Question:
Write the code to produce the desired output:
names = ("Bill", "Steve","Tim", "John")
Desired Output:
firstname = Bill
lastname = John
Others = ['Steve', 'Tim']
[bg_collapse view=”button-blue” color=”#ffffff” icon=”eye” expand_text=”Show Answer” collapse_text=”Hide Answer” ]
In [1]:
names = ("Bill", "Steve","Tim", "John")
firstname, lastname, *Others = names
print("firstname =",firstname)
print("lastname =",lastname)
print("Others =",Others)
[/bg_collapse]