I am diving into Python and I have a question about foreach 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 this.
Its also interesting to observe this
To iterate over the indices of a sequence, you can combine range() and len() as follows:
a = ['Mary', 'had', 'a', 'little', 'lamb']
for i in range(len(a)):
This is the way "continue" statement works!
You ...READ MORE
Machine Learning is a vast domain. It ...READ MORE
if x == 'a':
# Do the ...READ MORE
Easiest way: math.factorial(x) (available in 2.6 and ...READ MORE
suppose you have a string with a ...READ MORE
You can also use the random library's ...READ MORE
colors = ['red', 'green', ...READ MORE
can you give an example using a ...READ MORE
Polymorphism is the ability to present the ...READ MORE
Python doesn't have a native array data ...READ MORE
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.