Why isn't this working | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
31st May 2019, 5:24 AM
Y AD Ù
Y AD Ù - avatar
2 Antworten
+ 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)
31st May 2019, 5:57 AM
Jake
Jake - avatar
+ 2
Jake thanks
31st May 2019, 6:01 AM
Y AD Ù
Y AD Ù - avatar