I am pretty new to python and saw that we can get a dict by dict.fromkeys(keys, value)
, I am not sure why here you can use dict, not dict()
.?
For list and int or str, if use this
list.append(1)
TypeError Traceback (most recent call last)
<ipython-input-40-f15c629423f5> in <module>()
1
----> 2 list.append(1)
TypeError: descriptor 'append' requires a 'list' object but received a 'int'
and it doesn't work even with the list object
list.append([1])
TypeError Traceback (most recent call last)
<ipython-input-41-b98586d7f7ed> in <module>()
1
----> 2 list.append([1])
TypeError: append() takes exactly one argument (0 given)
if I
type(dict)
return type
what is 'type' type?
this might be a dumb question, but I could not find any answers online, anybody can help?