Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Delete List Elements in python

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 374
    Comment on it

    To remove a list element, you can use either the del statement if you know exactly which element(s) you are deleting or the remove() method if you do not know. For example

    #!/usr/bin/python
    
    list1 = ['physics', 'chemistry', 1997, 2000];
    
    print list1
    del list1[2];
    print "After deleting value at index 2 : "
    print list1

    Output will be->
    ['physics', 'chemistry', 1997, 2000] After deleting value at index 2 : ['physics', 'chemistry', 2000]

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: