Use for in Loop in Python

Loop is used to iterate the elements of a sequence.for Loop is used to display all elements of any sequence.

When iteration starts, an element of sequence is assigned to the variable and the given statement is executed. The iteration continues till the number of elements that are there and then the control of the loop comes out of the loop.

for in loop use in python, how to use for in loop in python, what is for in loop in python?

Syntax of for Loop

for variable in sequence
for_statement(s)

Example for Iterating list sequence Source Code :

a = [1, 2, 4, 5, 7, 8]
for n in a :
print(n)

Output :

1
2
4
5
7
8

 

else with for Loop

When the iteration of the elements of a sequence in the for loop is over, then the else statement; will execute

Source Code :

name = ['Rahul', 'Jyoti', 'Khushboo']
for i in name :
print(i)
else:
print("Outside of for Loop")

Output :

Rahul
Jyoti
Khushboo
Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.