Loops in python

Loops in python:

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

print "Goodbye"

Output:

Current Fruit: banana
Current Fruit: apple
Current Fruit: guava
print "Goodbye"

FOR Loop with index

fruits=['apple','mango','banana']

for index in range(len(fruits)):
    print'current fruit:',fruits[index]
print 'goodbye!!'

Output:

current fruit: apple
current fruit: mango
current fruit: banana
goodbye!!

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.