Doubt in Python Functions

Why there is no output of below program in Python, ideally it should error:

def add(x,y):
try:
print(x + y)
except:
(“Error in Processing”)

add (11,“boy”)

Hi, Ashish.

Your code is almost correct and your prediction also correct! that it should error.
You need to print the (“Error in Processing”) then only it will print the error right.

except:
    print("Error in Processing")

The except block is meant for writing our own custom error message that we need to show to the users for their better understanding. So that we can mask the error message given by the compilers.

All the best!

Thanks a lot… my bad… new to syntax :slight_smile:

def email_func(content):
position = content.find(’@’)
index = position
if position!= -1:
while index >=0 and content[index]!=’ ‘:
index-=1
first_part = content[index+1:position]
ending_position = content.find(’ ',position)
if ending_position == -1:
second_part = content[position:]
else:
second_part = content[position:ending_position]
return first_part + second_part
else:
return False

this program is too tough for me. I did not understand after anything after index = postion.

please help me to understand.

regards

nirav raj