Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
Can anyone tell me how to use for loop in Python?

1 Answer

0 votes
by (108k points)

If you want to iterate inside an array, a list, a tuple, or a dictionary, then the best way to do it is to use the for loop. You can refer to the below code for achieving the result:

fruits = ["apple", "banana", "cherry"] 

for x in fruits:

         print(x)

The output:

apple

banana

cherry

If you are looking for an online course to learn Python, I recommend this Python Certification program by Intellipaat.

Related questions

0 votes
1 answer
asked Nov 18, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
asked Sep 25, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jan 10, 2021 in Python by ashely (50.2k points)
0 votes
1 answer
asked Dec 12, 2020 in Python by ashely (50.2k points)

Browse Categories

...