jeudi 3 janvier 2019

Python3 Assign, Compare, Use value in one line

Current Code:

error = dict.get("error", None)
if error:
    print(error)

Is there a way to place it on one line

print(error) if (error = dict.get("error", None))

Since in C you can assign a value, then compare, then print it out on one line

if (a = 5) printf("%d",a);

Aucun commentaire:

Enregistrer un commentaire