0

Please help me fix this.

I want to make a function that show the sum of two numbers, but this doesn't work. def sumOf2(n1,n2): n1 = int(input()) n2 = int(input()) x = n1+n2 return x total = sumOf2

19th Aug 2021, 4:53 PM
Prasert Chaichana
Prasert Chaichana - avatar
3 Respostas
+ 2
https://code.sololearn.com/c8h4J7m110EH n1 = int(input()) n2 = int(input()) def sumOf2(n1,n2): x=n1+n2 return x total = sumOf2(n1,n2) print(total)
20th Aug 2021, 1:39 AM
Abhishek Kumar
Abhishek Kumar - avatar
+ 4
Your function doesn't need parameters if you take input inside the function Also you forgot the () when you call the function
19th Aug 2021, 4:56 PM
Lisa
Lisa - avatar
+ 1
As Lisa explained, the correct code is below: def sumOf2(): n1 = int(input()) n2 = int(input()) x = n1+n2 return x total = sumOf2() print(total) And you might want to add print at the end to see your result :)
19th Aug 2021, 5:28 PM
Musaab
Musaab - avatar