Q:

Write a Python program to remove a specified column from a given nested list

0

Write a Python program to remove a specified column from a given nested list

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def remove_column(nums, n):
   for i in nums: 
    del i[n] 
   return nums

list1 = [[1, 2, 3], [2, 4, 5], [1, 1, 1]]
n = 0
print("Original Nested list:")
print(list1)
print("After removing 1st column:")
print(remove_column(list1, n))

list2 = [[1, 2, 3], [-2, 4, -5], [1, -1, 1]]
n = 2
print("\nOriginal Nested list:")
print(list2)
print("After removing 3rd column:")
print(remove_column(list2, n))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now