Loop in python

Total Post:113

Points:791
 336  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

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.