remove() to remove item based on value from a list

All list methods

remove(x) takes one argument as matching value .

x : ( value ) first matching value to be removed

my_list=['Alex','Ronald','John']
my_list.remove('Ronald')
print(my_list)
Output is here
['Alex', 'John']

Having duplicate values

Only first matching value is removed.
my_list=['Alex','Ronald','John','Ronald','Ronn']
my_list.remove('Ronald')
print(my_list)
Output ( 2nd matching element Ronald is not removed. )
['Alex', 'John', 'Ronald', 'Ronn']
All list methods Questions with solutions on List


plus2net.com



Post your comments , suggestion , error , requirements etc here





Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer