Type hint for a dict gives TypeError: ‘type’ object is not subscriptable [duplicate]

I guess you should use Dict, e.g.:

from typing import Dict

memo: Dict[int, int] = {0: 0, 1: 1}

In your case, you were using dict which is of type type

>>> type(dict)
<class 'type'>
>>> type(Dict)
<class 'typing._GenericAlias'>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)