In ps3, the function "display_hand" (http://dpaste.com/804650/) seems to be returning None, which looks stupid when it interrupts every hand of the word game. Why does this happen, and how can I fix it?
how are you calling it?
The 'display_hand' routine does not say in the specification that it returns anything and it does not, nor does it need to. You simply call it with 'display_hand(hand)' and it iterates through the letters in hand and prints them out for you.
python functions always return something. if you do not tell it what to return, it will return None. http://pastie.org/4790675
in case it wasn't clear from the previous replies, the display_hand function has no return value specified. Instead, the function itself does the printing. If you run "print display_hand(hand)", it will display the hand as well as print the return value, which is "None" in this case. If you simply call the function print "Here is your hand" display_hand(hand) you will not have this problem.
Aha! I was printing display_hand. Thank you for the replies! I reworked the function to return the hand instead, like so: http://pastebin.com/wCtDj30R
here is another way to do it - using a list comprehension http://pastie.org/4816135
Join our real-time social learning platform and learn together with your friends!