Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

thepenguin

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?

  • one year ago
  • one year ago

  • This Question is Closed
  1. RoamingBlue
    Best Response
    You've already chosen the best response.
    Medals 1

    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

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.