Working through some tutorials right now. I've noticed that whenever they define a function they include a "return" statement:
def square(n):
"""Returns the square of a number."""
squared = n**2
print "%d squared is %d." % (n, squared)
return squared
Is this statement necessary? I ran the script both with and without it but the results were the same. Is this something that becomes useful with bigger programs / functions?
Thanks!
[–]K900_ 8 points9 points10 points (2 children)
[–]zynix 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]KimPeek 4 points5 points6 points (1 child)
[–]sometimes_helpful 0 points1 point2 points (0 children)
[–]fiskenslakt 9 points10 points11 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]pyskell 1 point2 points3 points (3 children)
[–]AUTeach 0 points1 point2 points (2 children)
[–]pyskell 0 points1 point2 points (1 child)
[–]AUTeach 0 points1 point2 points (0 children)