- If you mean to write list comprehension you missed
[
,]
: - There is no
is not in
operator. Usenot in
. type
function does not returnstring
. Why not useisinstance(item, int)
?
[lst.append(dict2obj(item)) if not isinstance(item, int) else lst.append(item)
for item in v]
Use simple for
loop if possible. It's more readable.
for item in v:
if not isinstance(item, int)
lst.append(dict2obj(item))
else:
lst.append(item)