December 23, 2014

Loop


  1. While loop
  2. count = 0
    while (count < 10):
      print “count = “, count
    count = count + 1
    print "end"
    
    
2.   for
In Python programming, we could put string, array and numbers in for loop. Quite different with C, C only could put numbers inside.
l   String
for letter in 'Python':     # First Example
   print 'Current Letter :', letter
Execution :
Current Letter : P
Current Letter : y
Current Letter : t
Current Letter : h
Current Letter : o
Current Letter : n



No comments :

Post a Comment