How to use python: continuously

inverse.setdefault(val, []).append(key)

what function does this sentence achieve? it is easy to understand using one method, but using two methods in a row. I don"t understand how the value is passed.

the following is the complete code

def invert_dict(d):
    inverse = {}
    for key in d:
        val = d[key]
        inverse.setdefault(val, []).append(key)
    return inverse
Mar.02,2021

inverse.setdefault (val, []) .append (key)

it is equivalent to:

>>> d = {}
>>> d.setdefault(1, []).append(2)
>>> print(d)
{1: [2]}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c2c950-33af2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c2c950-33af2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?