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

PREVIOUS NEXT
Code Example
Python :: how to say hello world 
Python :: alarm when code finishes 
Python :: how to clear a text file in python 
Python :: python http server command line 
Python :: convert letters to numbers in python 
Python :: flask for loops 
Python :: python insert image 
Python :: django update increment 
Python :: python windows take screenshot pil 
Python :: remove duplicates without changing order python 
Python :: install biopython in windows 
Python :: How to log a python crash? 
Python :: pandas read excel nan 
Python :: pandas subtract integer from column 
Python :: python cube root 
Python :: check if coroutine python 
Python :: avatar discord.py 
Python :: how to move a column to last in pandas 
Python :: rename files in folder python 
Python :: how to receive user input in python 
Python :: python r before string 
Python :: python delete the last line of console 
Python :: python matplotlib hist set axis range 
Python :: climate change 
Python :: display entire row pandas 
Python :: window in python 
Python :: how to get the live website html in python 
Python :: cvtcoloer opencv 
Python :: add header to table in pandas 
Python :: ignition create dataset 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =