I have a list like this:
array=['for','loop','in','python']
for arr in array:
print arr
This will give me the output
for
lop
in
python
I want to print
in
python
How can I skip the first 2 indices in python?
Use slicing.
array = ['for','loop','in','python']
for arr in array[2:]:
print arr
When you do this, the starting index in the for
loop becomes 2
. Thus the output would be:
in
python
For more info on slicing
read this: Explain Python's slice notation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With