Python Loops

[vc_row][vc_column width=”1/4″][/vc_column][vc_column width=”1/2″][vc_column_text]

for letter in 'Grafioo':
   print 'Current Letter :', letter

[/vc_column_text][vc_column_text]

Current Letter : G
Current Letter : r
Current Letter : a
Current Letter : f
Current Letter : i
Current Letter : o
Current Letter : o

[/vc_column_text][vc_column_text css=”.vc_custom_1617313726946{margin-top: 20px !important;}”]

fruits = ['banana', 'apple', 'mango'] 
for fruit in fruits: 
print 'Current fruit :', fruit 

[/vc_column_text][vc_column_text]

Current fruit : banana 
Current fruit : apple 
Current fruit : mango

[/vc_column_text][vc_column_text]

count = 0
while (count < 9):
   print 'The count is:', count
   count = count + 1

[/vc_column_text][vc_column_text]

The count is: 0
The count is: 1
The count is: 2
The count is: 3
The count is: 4
The count is: 5
The count is: 6
The count is: 7
The count is: 8

[/vc_column_text][/vc_column][vc_column width=”1/4″][/vc_column][/vc_row]

Scroll to Top