subset daftar python

# Creating a subset including elements at indexes 0, 1, 2, 4, 6, 7, 8
a = ['a', 'b', 'c', 3, 4, 'd', 6, 7, 8]
# List of indexes
b= [0, 1, 2, 4, 6, 7, 8]
# Create subset
c = [a[i] for i in b] # alternatively, c = a[0:2] + [a[4]] + a[6:]
Wissam