+ 1
Why does this code returns 2?
def func(): try: return 1 finally: return 2 k=func() print(k) there are supposed to be no error in try section, so if it returns anything it should be 1 and 2. or does 2 overwrites the return of 1?
2 Answers
+ 3
See this answer to a similar question on StackOverflow
https://stackoverflow.com/a/19805746
+ 2
The finally block is always executed. And a function can only return one object.