How to get all numbers from list which are located at multiple of 3 index for example
li=['ab','ha','kj','kr','op','io']
i need
['kj','io']
Use slicing on list where [2::3] means start from 2nd index(indices start from 0 in python) and get every 3rd element
print(li[2::3])
Output:
['kj','io']
for index,i in enumerate(li):
index = index+1
if index % 3 == 0: print(i)
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