new in programing
Mike C. Fletcher
mcfletch at rogers.com
Fri Dec 9 14:57:49 EST 2005
Python iterates over "things" (objects), of which integer numbers are
just one possible choice. The range built-in command produces ranges of
integers which are useful for tasks such as this.
lim = 3
for i in range( 1, lim+1 ):
for j in range( i+1, lim+2):
for k in range( j+1, lim+3):
for l in range( k+1, lim+4):
for m in range( l+1, lim+5):
for n in range( m+1, lim+6):
print i,j,k,l,m,n
Would be a direct translation of your code (with a few lines to make it
actually do something and a fix for the last variable name).
HTH,
Mike
Efrain Marrero wrote:
>i want to now how to do this in python
>this is java
>
>
>for(int i=1 ; i<=lim ; i++){
>
> for(int j=i+1; j<=lim+1; j++){
>
>
...
--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
More information about the Python-list
mailing list