- 1
how to find even index position which is divisible by 2 only
7 Réponses
+ 2
arr = [ 'a', 'b', 'c', 'd', 'e' ]
for index in range(0,len(arr),2):
print(arr[index],end='')
output:
ace
+ 1
l=[1,1,2,4,6,7,8]
[y for x,y in enumerate(l) if x%2==0 and y%2==0]
0
Try with modulus
if (x%2 == 0)
{
//do stuff
}
Where x is your index.
0
I want even index position with divisible by 2
0
look into Lambdas
0
l=[1,1,2,4,6,7,8]
[y for x,y in enumerate(l) if x%2==0 and y%2==0]
o/p:2,6,8