mercredi 2 janvier 2019

if-statement using string variable and dictionary returns always true

I'm writing a program that needs to execute some if statement which some of the variables inside a dictionary. However; although the if statement conditions aren't met, it still does execute the statement.

sOC = 'BUY|APPROXIMED'
fParameter = 45
iParameterLB = 50
iP = '0'
dictConfigurationsCopy = {'sELP':'BUY|TRIVIAL',
                          'sESP':'BUY|APPROXIMED',
                          'iNCP':'0'} 
if (sOC == dictConfigurationsCopy['sELP']
or fParameter < iParameterLB 
    and iP == dictConfigurationsCopy['iNCP']): 
    print('Y')

It returns ('Y') even if the sOC variable is not the same as in the dictConfigurationsCopy variable.

Aucun commentaire:

Enregistrer un commentaire