How to print every second item of a list in Python

1 Answer

0 votes
lst = ["python", "c", "java", "c++", "php", "c#", "cobol"]

every_second = lst[::2]
print(every_second)


'''
run:

['python', 'java', 'php', 'cobol']

'''

 



answered Dec 1, 2017 by avibootz
...