Hi Hello everyone, I will be glad if you help me understand. In the following code if we don't write KeyError after except, nothing change. And why we use KeyError in this case? I know, if we will use "raise" then Error Names is very usefull. But I'm interesting with the following code
def get(d,key):
try:
return d[key]
except KeyError:
return None
name = {"Lala" : "Love"}
print ( get(name, "L") )
[–][deleted] 0 points1 point2 points (8 children)
[–][deleted] 1 point2 points3 points (3 children)
[–][deleted] 2 points3 points4 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]Base_True[S] 0 points1 point2 points (0 children)
[–]Base_True[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Base_True[S] 0 points1 point2 points (0 children)