anonymous
  • anonymous
Can anyone give me a suggestion on how to get the letters into the word in the hangman game in ps2? I am trying to get it to input the letters in the appropriate place in a chain of dashes. For example, for the word 'happy', it would print this '-----'. What I can't get it to do is, like if i guess 'a', input 'a' into the place of the proper dash, i.e. '-a---'. Any suggestions?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
http://dpaste.com/hold/786671/ answerWord = 'happy' dashedWord = '_____' # Check for the following letterst (just to test) for letterGuessed in ('a', 'p', 'y', 'h'): # loop through the entire answer to see if that character is present for index in range(0,len(answerWord)): # if we find the letter if answerWord[index] == letterGuessed: # this here's the important bit ################################################### # you can't actually change strings in Python # so you have to create a new string and build it from the old one # this builds the new string from: # the substring from 0 up to but not including the letter we need to insert # plus the correct letter we need to add in # plus the substring from the NEXT letter to the end of the string dashedWord = dashedWord[0:index] + letterGuessed + dashedWord[index+1:len(dashedWord)] print dashedWord

Looking for something else?

Not the answer you are looking for? Search for more explanations.