22nd Aug 2024, 4:11 AM
Shivi Kushwaha
Shivi Kushwaha - avatar
5 Respostas
0
It returns nothing since in the way you’ve defined those functions, they need to be defined after the input has been taken to work, a better way to solve this would be by simply making the functions take X and Y as arguments like this: def sum(x, y) It will then work as intended. Another issue is that your code is hard to read, it doesn’t affect its functionality, but spacing operators, variables and values makes it look way more appealing, trust me it helps alot, make it a habbit!
23rd Aug 2024, 12:31 AM
Uwltoamym
Uwltoamym - avatar
+ 3
Shivi Kushwaha please have a look at this code as per the previous comments by Mihaly Nyilas and Ruben https://sololearn.com/compiler-playground/c5s5I0bXjN3M/?ref=app
22nd Aug 2024, 1:06 PM
BroFar
BroFar - avatar
+ 1
4 7 0 works properly in BroFar's code :-) 1st step: if a function, there is a return 2nd step: if it needed, use functional parameter(s)
22nd Aug 2024, 1:57 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
if you are using a function, then it have to give back something
22nd Aug 2024, 6:26 AM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
When you are defining the functions, you are declaring a=x something y, but you are not passing x and y as parameters of the function.
22nd Aug 2024, 8:32 AM
Ruben