This question already has an answer here:
In C# the ?? operator can be used as such
foo = Null;
var = foo ?? "Since Foo was null, var has been assigned this string as a value";
print(var);
>"Since Foo was null, var has been assigned this string as a value"
Is there an equivalent operator or method in Python?
P.S. I know I can use an if statement, but I am specifically curious if a quick method such as ?? exists.
Aucun commentaire:
Enregistrer un commentaire