Return statement doubt

def func():

    return 1
    return 2

func()

for the above code why doesnt it print 2? the output should be:
1
2
but it actually is:
1

Hey @devchopra999_11c6416ab7f09bbf,
So basically after return statement the control changes and goes directly to the calling function. So after return 1 nothing below it will work as control will go to the place where this func() was called and 1 was printed.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.