Answers for "can is slice list with list of indices python"

0

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]
Posted by: Guest on February-04-2022

Python Answers by Framework

Browse Popular Code Answers by Language