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

Nick the Gr33k support at superhost.gr
Fri Jun 14 08:31:54 EDT 2013


On 14/6/2013 3:03 μμ, Denis McMahon wrote:
> for i, month in enumerate(months):
>    if i != 0:
>      print('<option value="%s"> %s </option>' % (i, month) )
>    else:
>      print('<option value="%s"> %s </option>' % ("==========", month) )

This s exactly what i was looking for Denis, thank you.

I tough of that myself too, but i had implemented it wrongly as:

for i, month in enumerate(months):
	if i == 0:
		i = "=========="
	else:
		print('<option value="%s"> %s </option>' % (i, month))


I just cant think simple and clear some times.

Of course as you also said i could have left it as it it is and then 
look for month == 0 in the if condition instead of month == "============"


-- 
What is now proved was at first only imagined!



More information about the Python-list mailing list