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,870 points
39 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,160 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,750 points
33 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
79 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
• 56,520 points
406 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
• 56,520 points
400 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 215 views
0 votes
1 answer

Equivalent of a?b:c in Python

In Python 2.5, you can use ternary ...READ MORE

answered Jan 7 in Python by SDeb
• 13,160 points
32 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,160 points
228 views