+ 2
Why isn't this working
2 odpowiedzi
+ 3
The first two lines are correct, however you are trying to add two strings together where instead you need to be adding two integers as those are the types you have declared for x and y, so you need to remove the single-quotation marks as those specify a string type.
You also need to remove the + operator from the method declaration, as you can not perform math within method parameters, they are only meant to hold references. (You also need to add a colon after “def add(x,y)” as this will tell the compiler any code after the colon belongs to the declared method)
quite honestly I havent studied python so anyone feel free to correct me.
Anyway, this will get the functionality you are looking for:
x = int(input())
y = int(input())
def add(x, y):
print(x + y)
add(x,y)
+ 2
Jake thanks