Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I am diving into Python and I have a question about for each iteration. I am new to Python and I have some experience in C#. So I am wondering, if there is some equivalent function in Python for iteration all over all items in my collection, e.g.

pets = ['cat', 'dog', 'fish'] marks = [ 5, 4, 3, 2, 1]

or something like that.

1 Answer

0 votes
by (106k points)
edited by

The for each equivalent of Python is as follows:-

for f in pets: 

    print f

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
asked Sep 27, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Feb 16, 2021 in Python by ashely (50.2k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...