Loop in python

Total Post:113

Points:791
 159  View(s)
Ratings:
Rate this:

Explain For  loop in Python ?

  1. Post:140

    Points:984
    Re: Loop in python

    For loop in Python :

    A for loop is used for iterating over a sequence which is either a list,a tuple or a string. Ex: 

    fruits = ["apple", "banana", "cherry"] 
    for x in fruits:
      print(x)

    Break statement : 

    fruits = ["apple", "banana", "cherry"] 
    for x in fruits:
      if x == "banana":
        break
      print(x)


    continue statement :

    fruits = ["apple", "banana", "cherry"] 
    for x in fruits:
      if x == "banana":
        continue
      print(x)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!