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

Hi guys, i am in the middle of programming the hangman game from the second problem set, and I keep getting "TypeError: expected a character buffer object". How can I fix this? Here is the code that is causing the trouble: while numGuesses > 0: #or print '------------' print 'you have ' + str(numGuesses) + ' guesses left' avaLetters = 'abcdefghijklmnopqrstuvwxyz' print 'available letters: ' + avaLetters guess = realWord.find(raw_input('please guess a letter: ')) print avaLetters.index(guess) print 'letter is: ' + letter print avaLetters print '_

OpenStudy (anonymous):

Hey there, could you dpaste the entire file, I'll take a quick look but I need to see the other functions that are getting called. dpaste is here: http://dpaste.com/ It'll let you paste the whole thing up, click to format it for python, then give you a link you can post here. It makes it a lot easier to cut and paste the code to run it 'cause the formatting goes all wonky if you cut from a forum post.

OpenStudy (anonymous):

here you go: http://dpaste.com/785922/

OpenStudy (anonymous):

guess = realWord.find(raw_input('please guess a letter: ')) on line 68 realWord.find isn't an actual function so guess is getting set to -1 which makes print avaLetters.index(guess) fail because it's trying to find the index of -1 instead of a letter try changing line 68 to just a run of the mill raw input print avaLetters.find(guess) That should get you back in business.

OpenStudy (anonymous):

ok, thanks. I'll give it a try.

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!