Need explanation also

def sree(s):
try :
num=int(s)
print(“sucess”)
except TypeError:
print(“failure case”)
num=-1

l=[1,2,3]

sree(l)

1 Like

When you run this code, it will call the sree function with the list l as the argument. However, since converting a list to an integer will raise a TypeError , it will print “Failure case” instead of “Success”. Additionally, it will assign -1 to num after the exception handling block.

2 Likes

thnaks for the reply ji

1 Like