Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to print alternate numbers in python

list = [1,2,3,4,5]
alternate_list = list[::2] 
#as we are looking for even indices only, and 2 is the smallest even number
#so, using list[::2] slices every second item of the list 
for item in alternate_list:
  print(item)
 
#Hope this helps:)
Comment

PREVIOUS NEXT
Code Example
Python :: how to make a never ending loop in python 
Python :: split multiple times 
Python :: binary number in python 32 bit 
Python :: code for making an exe file for python 
Python :: select columns from dataframe pandas 
Python :: python regex remove digits from string 
Python :: matplotlib create histogram edge color 
Python :: python how to get directory of script 
Python :: string pattern matching pandas 
Python :: add a title to pandas dataframe 
Python :: np replace nan 
Python :: pyqt latex 
Python :: set python3.7 as default ubuntu 
Python :: get the system boot time in python 
Python :: how to download youtube playlist using python 
Python :: delete turtle 
Python :: python datetime subtract seconds 
Python :: ModuleNotFoundError: No module named ‘click’ 
Python :: get the last element of a list python 
Python :: convert list to binary python 
Python :: how to reverse array in ruby 
Python :: python read music stream 
Python :: godot string format 
Python :: Get Key From value in dictionary 
Python :: import random py 
Python :: python datetime to utc 
Python :: get all values of a dict python 
Python :: openpyxl delete column by name 
Python :: how to print all combinations of a string in python 
Python :: convert set to list python time complexity 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =