0

I am supposed to create a program in which I am supposed to add numbers if they are string and concatenate numbers if they are integer. This is my code:

num1 = input("Enter an integer or string: ")
num2 = input("Enter an integer or string: ")
  def stupid_addition(num1, num2):
    if (num1, num2) == str:
      result = int(num1 + num2)
    else:
      result = str(num1 + num2) 
    return result
stupid_addition(num1, num2)
AndrewL64
  • 15,794
  • 8
  • 47
  • 79
ailiya
  • 1
  • 1

1 Answers1

0

You need to print the result, using the print function.

num1 = input("Enter an integer or string: ")
num2 = input("Enter an integer or string: ")
def stupid_addition(num1, num2):
  if (num1, num2) == str:
    result = int(num1 + num2)
  else:
    result = str(num1 + num2) 
  return result

print(stupid_addition(num1, num2)) 
Sander Bakker
  • 611
  • 2
  • 12
  • 32