Django Python If statement not producing the expected result -


the following code if run in python console worked fine , able expected result:

c2 = 1 stepcount = 4 workstepno = 4 exequenum = 5  if c2 == 1:     if stepcount == workstepno:             if exequenum == 5:                 actionchoice1 =3             else:                 actionchoice1 = 2     else:             stepcount= int(stepcount)+1             actionchoice1 = 1 else:     actionchoice1 = 0  print "actionchoice1", actionchoice1 

was able print out on python console on actionchoice1 correctly 3.

however, when same code used in django produced actionchoice 2 , not 3 expected.

if c2 == 1:     if stepcount == workstepno:         if exequenum == 5:             actionchoice =3         else:             actionchoice = 2     else:         stepcount= int(stepcount)+1         actionchoice = 1 else:     actionchoice = 0    

please pinpoint errors might have caused this. other alternative can used expected result in django python

        if exequenum == 5:             actionchoice =3         else:             actionchoice = 2 

actionchoice 2 when exequenum not 5. please check how you're retrieving/producing value of exequenum on django. not equal 5.

update:

as op mentions, value unicode string. needs integer compared integer (5 in case).

so this:

    exequenum = int(exequenum)     if exequenum == 5:         actionchoice =3     else:         actionchoice = 2 

or can if int(exequenum) == 5 if don't want change type of variable.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -