A quick question using python -
When we use remove() method in list and the set we get different error one is giving Value error and other one return key error, is there any specific reason??
Python
s = [10,20,30,40]
s.remove(50)
print(s)
Traceback (most recent call last):
s.remove(50)
ValueError: list.remove(x): x not in list
-------------------------------------------
s = {10,20,30,40}
s.remove(50)
print(s)
Traceback (most recent call last):
s.remove(50)
KeyError: 50
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jun 29, 2021, 6:28 AM EDT
Salman BegRank #284 · 8.8K reputationPosted Jun 29, 2021, 6:17 AM EDT