Python List by Picking First List Odd-Index and Second List Even-Index || Python
In this we are going to see a basic program to create a list by picking first list odd index and second list even index in Python Programming Language.



list1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
# odd-indexed elements are selected
list3 = [x for x in list1 if list1.index(x) % 2 != 0]
# even-indexed elements are selected
list3 += [x for x in list2 if list2.index(x) % 2 == 0]
print(list3)

# Coded by Shreya Idate


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post