Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to slice odd index value from a list in python using slice function

num = [1,2,3,4,5]
res = num[slice(1, len(num)-1, 2)]
print(res)
Comment

how to slice even index value from a list in python using slice function

num = [1,2,3,4,5]
res = num[slice(0, len(num), 2)]
print(res)

#[1, 3, 5]
Comment

can is slice list with list of indices python

lst = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
indices = [0, 2, 6]
out = [lst[i] for i in indices]
Comment

PREVIOUS NEXT
Code Example
Python :: nohup python command for linux 
Python :: python turtle write 
Python :: conda env 
Python :: python run all tests 
Python :: MovieWriter stderr: ffmpeg: error while loading shared libraries: libopenh264.so.5: cannot open shared object file: No such file or directory 
Python :: negative index in python list 
Python :: python refresh import 
Python :: django logout user 
Python :: python list comprehension elif 
Python :: pandas profile 
Python :: python get attributes of class 
Python :: python reverse a string 
Python :: python print raw string 
Python :: pyspark overwrite schema 
Python :: delete directory if exists python 
Python :: how to reset index after dropping rows pandas 
Python :: get all file in folder python 
Python :: pandas read from txt separtion 
Python :: get rid of unnamed column pandas 
Python :: The Python path in your debug configuration is invalid. 
Python :: import local module python 
Python :: randomforestregressor in sklearn 
Python :: twin axis python 
Python :: How to generate all the permutations of a set of integers, in Python? 
Python :: endswith python 
Python :: python nth prime function 
Python :: elif in django template 
Python :: multiple variables in for loop python 
Python :: python subprocess stdout to dev null 
Python :: write a python program to find table of a number using while loop 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =