Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 17 Online
OpenStudy (anonymous):

I get a weird error every time I run this program for ps6. The program works fine but I get a extra line with "None" in it every time it loops through the play_hand. Any ideas? http://dpaste.com/hold/565450/

OpenStudy (anonymous):

i put some print statements in to pinpoint it: i started with one print statement to see if it was happening before or after a certain line, then added more till i had it 'bracketed'. i used print 'print1' (and 'print2' ...) http://dpaste.com/565459/ i think I know why but i'll give you a chance to figure it out.

OpenStudy (anonymous):

I can't really tell. It just seems like there is a phantom print "None" after "print 'Current Hand:', display_hand(hand)" and "print 'print1'"

OpenStudy (anonymous):

"display_hand" prints results itself but does not return the hand back to "play_hand". when you call "display_hand" in "play_hand" you have a print statement so it prints what it got returned from "display_hand" which is by default "None". Change display_hand to return rather than print and the problem goes away.

OpenStudy (anonymous):

I don't know if you want the answer but here it is http://dpaste.com/565476/

OpenStudy (anonymous):

I understand now, but can you just make a function return nothing instead of None?

OpenStudy (anonymous):

my understanding is that a function always returns "something" but I suppose I could be mistaken.

OpenStudy (anonymous):

ok. thanks for the help!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!