remove function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

remove function

https://code.sololearn.com/coU5hRkUDu82/#py why does 'remove' only the first occurring element ??

5th Apr 2020, 1:40 PM
Mani
Mani - avatar
1 Answer
+ 3
You can define a function to achieve your task . def remove(x,y): for i in range(len(x)): try: x.remove(y) except: continue return x #take (x) argument as list #and take (y) argument as the string to remove
5th Apr 2020, 2:03 PM
Tricker