Syntaxe python scope variable
Hello,
Débutant total sur python, je cherche à faire varier la variable d'un booleen au sein de 2 conditions dans un petit algo qui aura un comportement différent selon l'état du booléen (variable "first_alert_temp")
Je galère à déclarer ma variable "first_alert_temp" sans succès. J'ai essayé de la décarer dans l'espace global. La déclarer dans le scope de la fonction n'aurait pas de sens
Code:
1 2 3 4 5 6 7 8 9
|
def scanner(temp):
global first_alert_temp = False
if (temp > 30 or temp < 24) and first_alert_temp is False:
print("salut")
first_alert_temp = True
elif (temp < 30 or temp > 24) and first_alert_temp is True:
print("Au revoir") |
Merci pour votre aide