Basic question

sturlamolden sturlamolden at yahoo.no
Sat May 12 19:35:40 EDT 2007


On May 12, 6:18 pm, "Cesar G. Miguel" <cesar.go... at gmail.com> wrote:

> Am I missing something?

Python for loops iterates over the elements in a container. It is
similar to Java's "for each" loop.

for j in range(10):
  print j
  if(True):
       j=j+2
       print 'interno',j

Is equivalent to:

int[] range = {0,1,2,3,4,5,6,7,8,9};
for (int j : range) {
   system.out.writeln(j);
   if (true) {
     j += 2;
     system.out.writeln("iterno" + j);
   }
}

If I remember Java correctly...







More information about the Python-list mailing list