You can download this code by clicking the button below.
This code is now available for download.
Define a function that takes two arguments, adds them using a nested function, then attempts to convert the result to an integer. If the conversion fails, it returns the result as a string.
Technology Stack : Built-in functions (def, return, int, try-except)
Code Type : Function
Code Difficulty : Intermediate
def aaaa(arg1, arg2):
def bbbb():
return arg1 + arg2
def cccc():
try:
return int(bbbb())
except ValueError:
return str(bbbb())
return cccc()