A certainl part of an if() structure never gets executed.

Andreas Perstinger andipersti at gmail.com
Wed Jun 12 06:07:54 EDT 2013


[Please trim your replies to the relevant parts.]

On 12.06.2013 10:54, Νικόλαος Κούρας wrote:
> But when it comes to select '==========' from month instead of
> '==========' to be submitted a zero gets submitted and i think the
> problem is the way i'm filling up months into the drop down menu which is:
>
>
> for i, month in enumerate(months):
>       print('<option value="%s"> %s </option>' % (i, month) )
>
>
> the if case does not execute because of the way it checks for None entry
> which is: elif '=' not in year:
>
> but if enumerate yields 0 instead of '==========' then elif '=' not in
> year of course fails.

How often do we need to tell you that you should reread your posts 
before sending them?
You start with telling us you have problems with "month" and then show 
us code regarding "year"

> So, i must tell:
>
> for i, month in enumerate(months):
>       print('<option value="%s"> %s </option>' % (i, month) )
>
> to somehow return '==========' instead of 0 but don't know how.

As with most of your problems you are barking up the wrong tree.
Why not use the actual value you get from the form to check whether you 
have a valid month?
Do you understand why "0" is submitted instead of "=========="?

Bye, Andreas



More information about the Python-list mailing list