+ 1

Functions as objects

can someone say why I am not getting any output https://code.sololearn.com/c4ZDXn322VVW/#py

29th May 2020, 4:31 PM
Mani
Mani - avatar
2 odpowiedzi
+ 4
when you invoke a function you just need the parameters for the main function in your case. and indentation was also a problem. the code below works perfectly fine. since you define an inner function, you don't need to use the outer function as a parameter because the scope handles that for you. also. the issue here is that you can have only one return. if return is reached your code will exit the function. you can use only ONE return in a function def calc(x,y): return x+y def Enter_the_no(x,y): return calc(x,y) print(calc(6,7)) to get all operations you want you could do this instead: def calc(x,y): print (x+y) print (x-y) print (x*y) print (x/y) print (x%y) def Enter_the_no(cal,x,y): return calc(x,y) calc(6,7)
29th May 2020, 4:42 PM
Sebastian Pacurar
Sebastian Pacurar - avatar