It works fine when u run it but gives an error when submitted.. |
|
You're printing the values instead of returning them so wats the big deal.. 2
A BUG in their logic? Hmm.. not really. It is not a bug in their logic. It's a bug in yours. If you have a function that is supposed to return something, and it doesn't, the program doesn't work. Quick example: def square(number):
return number * number
x = 5
answer = 5 + square(x)
print answer
would exectute and the result of the program would be: 30 Change the return to a print: def square(number):
print number * number
x = 5
answer = 5 + square(x)
print answer
and you now have a program that doesn't work :p So the moral of the story is, use return when you're supposed to return something, and print when you're supposed to print it. 'print' versus 'return': To print or Not to print May provide you with some guidance. |