Python - Polymorphism and Dynamic Behavior
Write a polymorphic function combine that accepts either two strings or two lists and returns their concatenation. What is the output of this code?
def combine(a, b):
if isinstance(a, str) and isinstance(b, str):
return a + b
elif isinstance(a, list) and isinstance(b, list):
return a + b
else:
return None
print(combine('Hi, ', 'there!'))
print(combine([1, 2], [3, 4]))
print(combine('Hello', [1, 2]))