Tag Archives: for loop

Python- The Loops

The while loop 

To test the while loop copy the code as below:

lv_counter = 0
while (lv_counter < 10):
print(“The counter value is: “,lv_counter)
lv_counter = lv_counter + 1


Make sure to ident the block as shown below


Once you run the program, you should get the output as shown below

The for loop

You can iterate over a range of number or strings or lists.

for number in range(1,10):
print (“Current number is : “,number)

for letter in ‘Tutorial’:
print(“Current letter is :”,letter)

places = [‘Dhaka’,’Islamabad’,’Thimpu’,’New Delhi’]
for place in places:
print(“You are in this city now :”,place)

In the same file created above, add the above lines as shown below”:


Once you’ve run the program, you should see the output as shown below: