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

ok, I should be done, but I'm not, my code has passed all of the tests, the problem here is how display_hand displays one character per line. Also choosing to play more than once per hand is giving me issues, but I'll figure that out on my own I think. NOTE: I am using python 3, hence the input() vs raw_input() and the print() as a function. here's my code http://paste.org/pastebin/view/38082 any ideas are more than welcome

OpenStudy (anonymous):

erm, that question is for PS 5

OpenStudy (anonymous):

try using print(letter, end='') #those are two single quotes with nothing enclosed after end = in line 108 (in that link you posted).

OpenStudy (anonymous):

when a function returns a boolean (True or False) you can use it in a conditional statement without a comparison - in line 239, "is True' isn't necessary: you can (some would say should) just use "if is_valid_word(word, hand, word_list):" i think you have another problem: is_valid_word is modifying the hand that is passed to it: http://pastebin.com/hHcLTkmi

OpenStudy (anonymous):

Excellent point bwCA. jesse.bo, mutable objects like lists and dictionaries get passed by reference in Python. For us, that means that it is possible to modify these objects within a function and affect the original. So, we have this example: http://codepad.org/TvCbr2QH def ref_no_change(myDict): tempDict = myDict.copy() # we create a new object for a mutable object copy tempDict['a']=0 def ref_change(myDict): tempDict = myDict # we do not create a new object for a mutable object assignment myDict['a']=0 aDict = {'a':1} print('Dictionary before functions:',aDict['a']) # returns 1 ref_no_change(aDict) print('Dictionary after ref_no_change:',aDict['a']) # returns 1 ref_change(aDict) print('Dictionary after ref_change:',aDict['a']) # returns 0, oh noes!

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!