I cant seem to understand that why wont the function one_good_turn (which i later called ) print something


#1

def one_good_turn(n):
return n + 1
result = n + 1
print “The value of n is %d” (result)

def deserves_another(n):
return one_good_turn(n)

one_good_turn(6)


#2

By default, a function returns None at the end of the function. If we want to return something else at the end of the function, we can use the return keyword.

Given return is the last thing a function does, when a return keyword is reached, the function ends

so code after a return will never execute, some editors warn for this. So you would have to move the print statements if you want to see the print statements in action


#3

So do i have to move the print function before the return function??? BTW thanks so much


#4

Did you try this before asking this question? Ideally, you should.

neither return or print are functions or function calls in python2, they are statements.


#5

I am learning py3 also so thats why but can u give me the solution to printing the string plz


#6

i explained why it wasn’t working, then you asked a question which seem to indicate you understood the problem, now you just need to apply the fix?


#7

Hey i tried wot u said but it wont print ? wot should i do?


#8

place the return keyword at the end of your function


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.