OpenStudy (anonymous):

Regarding problem set 3, the word game. While trying to put my 'play_hand()' together, i noticed that whenever I use the "display_hand(hand)" it will print out the hand, followed by 'none.' e.g. a x x l l l e none My question is, how to debug 'display_hand()' to get rid of that 'none.' Thanks!

3 years ago
OpenStudy (anonymous):

The code body is: def display_hand(hand): """ Displays the letters currently in the hand. For example: display_hand({'a':1, 'x':2, 'l':3, 'e':1}) Should print out something like: a x x l l l e The order of the letters is unimportant. hand: dictionary (string -> int) """ for letter in hand.keys(): for j in range(hand[letter]): print letter, # print all on the same line print # print an empty line

3 years ago
OpenStudy (anonymous):

This code was provided, I didn't construct it.

3 years ago
OpenStudy (anonymous):

Never mind, got it. It was a syntax error on my part. print "Current hand: ", display_hand(hand) #produces 'none' value after the hand. #but print "Current hand: ", display_hand(hand) #prints correct format with no 'none' value. Just in case anyone with the same problem looks at this. Although I still don't really understand why this happens.

3 years ago
OpenStudy (anonymous):

We would need to see the code or return value of display_hand, as that's where it looks like the issue is coming in.

3 years ago
OpenStudy (anonymous):

You are Printing a fuction with no return, displayhand() only has print commands ie, def noReturn(): pass print noReturn() will output None

3 years ago
Similar Questions: