how to print alternate numbers in python code example
Example: 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:)