Computer Science, asked by jems1011, 11 months ago

Write a Python program to print a specified list after removing the elements based on another list which has index positions to be removed as data.

Answers

Answered by poojan
15

Python program:

#Let us take a list of elements from the user. [A string and split elements by a comma followed by space.

elementlist = list(input().split(' '))

#Take a list of indices and sort them into descending order so that we can keep on removing the elements in the index without disturbing the position of the remaining elements in the list. Separated by a ',' followed by a space.

#map the value with int() as the index value is always an integer.

indexlist = list(map(int,input().split(' ')))

indexlist = sorted(indexlist)[::-1]

#Remove elements using list.pop(index)

for i in indexlist:

     elementlist.pop(i)

print(elementllist)

Input:

arjun, karan, shreya, pallavi, 9, 3.82, brainly

2, 0, 6, 4

Output:

[karan, pallavi, 3.82]

Learn more:

1) Printing all the palindromes formed by a palindrome word.

brainly.in/question/19151384

2) Indentation is must in python. Know more about it at:

brainly.in/question/17731168

Similar questions