Computer Science - Class 12
Chapter 14 - Functions in python

Write a function called remove First that accepts a list as a parameter. It should remove the value at index 0 from the list. Note that it should not return anything (returns None). Note that this function must actually modify the list passed in, and not just create a second list when the first item is removed. You may assume the list you are given will have at least one element.

 

Answer:

def removeFirst (l):

    l.pop( 0 )

    return

 

Explanation:

  • The pop( ) function is an built-in function which removes the element at the position mentioned as the argument.
  • ‘l’ is the list .
Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo