Is there shorthand for returning a default value if None in Python? [duplicate]

In C#, I can say x ?? "", which will give me x if x is not null, and the empty string if x is null. I’ve found it useful for working with databases.

Is there a way to return a default value if Python finds None in a variable?

4 Answers
4

Leave a Comment