Use the asterisk (*) in front of a variable like this *variable_name to pack the leftover elements of a list into another list.Unpacking assigns elements of the list to multiple variables.It packs the last two elements in a new list and assigns the new list to the other variable. ![]() This example assigns the first and second elements to variables. And it assigns the last element of the list to the other variable. This example assigns the first and second elements of the colors list to the red and green variables.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |