I am trying to verify a variable condition to be greater than 0 and then if so then the text variable would be true. I have a fair amount of these as notifications I want to display in my code but for the sake of my question I will only list three here is my code:
notifications1 = 137
if notifications1 > 1:
text1 = [{
'link': 'error1',
'icon_class': 'fa',
'icon': 'fa-calendar-check-o',
'color': 'info',
'text': description
}]
notifications2 = 0
if notifications2 > 1:
text2 = [{
'link': 'error1',
'icon_class': 'fa',
'icon': 'fa-calendar-check-o',
'color': 'info',
'text': description
}]
notifications3 = 47
if notifications3 > 1:
text3 = [{
'link': 'error1',
'icon_class': 'fa',
'icon': 'fa-calendar-check-o',
'color': 'info',
'text': description
}]
else:
text = [{
'link': 'error1',
'icon_class': 'fa',
'icon': 'fa-calendar-check-o',
'color': 'info',
'text': 'There are no errors!'
}]
return text, text1, text2, text3
When I run this I get the error "UnboundLocalError local variable 'text3' referenced before assignment". Basically if the number is greater than 0 I want it to display the text variables and not skip any when it reaches one that is 0. I appreciate any insight on getting me in the right direction for this!
Aucun commentaire:
Enregistrer un commentaire