making variable if it is none python
var = None
if var == None:
var = ""
print(var)
making variable if it is none python
var = None
if var == None:
var = ""
print(var)
pythonhow to check if value is None
# How to check if a variable is None
var = None
# variable is None in this example
if var is None:
# if var is None
print("var is None")
# code...
else:
# if var is not None
print("var is not None")
# code...
# result of above example "var is None"
var = "sometext"
# variable is not None in this example
if var is None:
# if var is None
print("var is None")
# code...
else:
# if var is not None
print("var is not None")
# code...
# result of above example "var is not None"
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us