foreach equivalent in Python

0 votes

I am new to Python and I have some experience in C#. I am looking for an equivalent function in python for iteration of all the items in collection.

For example:

names = ['joy', 'sam', 'dan']
marks = [ 3, 4, 7, 2, 1]
Oct 4, 2018 in Python by ana1504.k
• 7,910 points
1,535 views

1 answer to this question.

0 votes

You can use a for loop as an equivalent as such:

for f in names:
    print f
answered Oct 4, 2018 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

What is equivalent for 'foreach' in Python

Its also interesting to observe this To iterate ...READ MORE

answered Oct 17, 2018 in Python by findingbugs
• 4,780 points
2,463 views
0 votes
1 answer

Is there a foreach function in python and is there a way to implement it if there isnt any

Every occurence of "foreach" I've seen (PHP, ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
1,152 views
0 votes
1 answer

The equivalent of a GOTO in python ​​

Gotos are universally reviled in computer science ...READ MORE

answered Sep 3, 2018 in Python by Priyaj
• 58,020 points
12,698 views
0 votes
1 answer

'foreach' function in Python 3?

Yes, there is a "foreach" in python. ...READ MORE

answered Oct 24, 2018 in Python by Priyaj
• 58,020 points
8,636 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
2 answers

Equivalent of a?b:c in Python

result = "F" if(isfemale_bit) else "M" print(result) Try this ...READ MORE

answered Dec 15, 2019 in Python by Manel
4,187 views
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,300 points
2,349 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP