while loop

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Tue Oct 11 14:30:06 EDT 2016


dhawanpawan32 at gmail.com writes:

> n=6
> x=1
> while x<=n:
>     print "*"*x
>     x+=1
> while n>=x:
>     n=n-1
>     print "*"* n
>
>   
> Only first loop is executing not the second one?

It's a basic fact about while loops that after the loop the condition is
false. The two conditions x <= n and n >= x are equivalent.



More information about the Python-list mailing list