is there smart way write following code in 3 or 4 lines?
a=l["artist"] if a: b=a["projects"] if b: c=b["project"] if c: print c
so thought pseudocode:
a = l["artist"] if true:
i don't think better do:
try: c = l["artist"]["projects"]["project"] except (keyerror, typeerror) e: print e pass
Comments
Post a Comment