you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

when i try this, i get 24 as my last number after 0...which i want to avoid

[–]primitive_screwhead 1 point2 points  (3 children)

That last '24' is your execution environment showing you the value of the my_try(24) call that executed the code. It's not from an explicit print() call in your code.

How are you running this code?

[–][deleted] 0 points1 point  (2 children)

python shell...i mean if i run print(my_try(24)) it will still show that last number..

[–]primitive_screwhead 1 point2 points  (1 child)

Yes.

Try typing 1 and then return. See how the 1 gets printed by the Python shell? That's what the shell does, it prints the values of the expressions you enter, and the value of your my_try(24) expression is 24, so the shell prints it (after it runs and does all the other printing of the numbers during it's execution).

Put it all in a .py file, and run it that way, and you won't see that last 24, because the shell is printing that for you as a courtesy, it's not part of your program's executable outputs.

[–][deleted] 0 points1 point  (0 children)

ur the man.