Hello, I'm fairly new to programming, and am working on a project for a programming class. I've run into a problem, and need some help...
I'm writing a hangman game and I'm having trouble getting the guessed letter to replace the correct hidden letter. Say the word is DICTIONARY, if the guess is "A", I can't get ********** to become *******A**... I tried test=word , I get a string index out of range error....any help would be greatly appreciated, thanks =)
oh...for graphical representation, i'm using a graphics library that was written by the writers of the textbook that my class is using, but I left out the code for that to reduce clutter...
from random import *
def wordsSetup():
wordBank = "DICTIONARY","YAHWEH","HANG","MUSIC","ORCHESTRA","GREEN","HYPERBOLE","DESTRUCTION","PYTHON","FRUSTRATION","EXTRA"
x=randint(0,9)
print x
for i in range(10):
if i == x:
word=wordBank[i]
return word
def main():
word=wordsSetup()
for i in range(len(word)):
test="*"*(i+1)
print word #test purposes
guess1=raw_input("Enter Guess in Caps ")
print guess1
for i in range(len(word)):
print word[i]
if guess1==word[i]:
test[i]=word[i]
print test
return 0
main ()