Unpacking operators * and ** ============================ Unpacking tuples or lists ------------------------- .. interactive_code_block:: :caption: A list cannot be used directly flies_like = ['an arrow', 'a banana'] print('Time flies like {}, fruit flies like {}!'.format(flies_like)) .. interactive_code_block:: :caption: One way is to 'unpack' the items of the list flies_like = ['an arrow', 'a banana'] print('Time flies like {}, fruit flies like {}!'.format(flies_like[0], flies_like[1])) .. interactive_code_block:: :caption: A shorter way of unpacking a list is to precede its name with an '*' flies_like = ['an arrow', 'a banana'] print('Time flies like {1}, fruit flies like {0}!'.format(*flies_like)) Unpacking dictionaries ---------------------- .. interactive_code_block:: :caption: A dict can unpacked by preceding its name with '**' flies_like = {'time': 'an arrow', 'fruit': 'a banana'} print('Time flies like {time}, fruit flies like {fruit}!'.format(**flies_like)) .. https://note.nkmk.me/en/python-tuple-list-unpack/