2016. 1. 18.

python for loop


Python loop syntax 

for item in list :
  action

ex) list
men = ["a", "b", "cxx"]
for man in men :
  print "man is %s" %( man)

ex) range
for idx in range(10) :
  print "idx is %d" %( idx)

ex) map
maps = { "a":11, "b": 12}
for m in maps :
  print "%s -> %s" % ( m, maps[m] )   # m is not an object, it is a key. !!

댓글 없음:

댓글 쓰기