Originally posted by St33med
If aList is a list of indexes, you need to
Code:
b[aList][indexintothislist] = str(choice)
b[aList][indexintothislist] = str(choice)
import sys # used to exit
def guess(count,addCount,letters):
choice=raw_input("Guess!(lowercase only please!)")
aList=indexList(word, choice)
print aList
if len(choice)>1:
print "Don't cheat!" # Exactly :)
guess(count,addCount,letters)
elif aList!=[-1]:
line[aList]=str(choice) #Problem here. aList is list when needs to be integers
print "Good Choice!"
c=''.join(line)
print c,"Letters missed:", letters #Tells what letters the guy has missed
if word==c:
print "You Win!"
sys.exit()
else:
guess(count,addCount,letters) #repeats until win or lose
else:
if choice in letters:
print "You have already guessed this!" #so he/she doesn't repeat a stupid mistake
guess(count,addCount,letters)
count+=addCount
letters[count]=choice
if count==0:
print "O"
addCount=1
elif count==1:
print "O<"
addCount=2
elif count==2:
print "0<-"
addCount=3
elif count==3:
print "O<-<\n Game Over XP"
sys.exit()
print "Letters missed: ", ' '.join(letters)
guess(count,addCount,letters)
def indexList(s, item, i=0):
i_list = []
while True:
try:
i = s.index(item, i)
i_list.append(i)
i += 1
except:
i_list.append(-1)
break
return i_list
if __name__=='__main__':
word=raw_input("Type a name:")
word=''.join(word.lower().split(' '))
#print word #This was just for testing
line=['_ ']*len(word)
print ''.join(line)
count=0 #set count
addCount=0 #set add count
letters=['']*4 #make an empty list
guess(count,addCount,letters)
import sys # used to exit
def guess(count,addCount,letters):
choice=raw_input("Guess!(lowercase only please!)")
aList=indexList(word, choice)
print aList
if len(choice)>1:
print "Don't cheat!" # Exactly :)
guess(count,addCount,letters)
elif aList!=[-1]:
line[aList]=str(choice) #Problem here. aList is list when needs to be integers
print "Good Choice!"
c=''.join(line)
print c,"Letters missed:", letters #Tells what letters the guy has missed
if word==c:
print "You Win!"
sys.exit()
else:
guess(count,addCount,letters) #repeats until win or lose
else:
if choice in letters:
print "You have already guessed this!" #so he/she doesn't repeat a stupid mistake
guess(count,addCount,letters)
count+=addCount
letters[count]=choice
if count==0:
print "O"
addCount=1
elif count==1:
print "O<"
addCount=2
elif count==2:
print "0<-"
addCount=3
elif count==3:
print "O<-<\n Game Over XP"
sys.exit()
print "Letters missed: ", ' '.join(letters)
guess(count,addCount,letters)
def indexList(s, item, i=0):
i_list = []
while True:
try:
i = s.index(item, i)
i_list.append(i)
i += 1
except:
i_list.append(-1)
break
return i_list
if __name__=='__main__':
word=raw_input("Type a name:")
word=''.join(word.lower().split(' '))
#print word #This was just for testing
line=['_ ']*len(word)
print ''.join(line)
count=0 #set count
addCount=0 #set add count
letters=['']*4 #make an empty list
guess(count,addCount,letters)
line[aList][count]=str(choice) # index into a list of indexes
TypeError: list indices must be integers
elif len(aList) > 0:
for i in aList:
line[i] = choice # is not choice already a string?
..............................................................................
elif len(aList) > 0:
for i in aList:
line[i] = choice # is not choice already a string?
..............................................................................
import sys # used to exit
def guess(count,addCount,letters):
choice=raw_input("Guess!(lowercase only please!)")
aList=indexList(word, choice)
print aList
if len(choice)>1:
print "Don't cheat!" # Exactly :)
guess(count,addCount,letters)
elif len(aList) > 0:
for i in aList:
line[i] = choice #Problem here. aList is list when needs to be integers
print "Good Choice!"
c=''.join(line)
print c,"Letters missed:", letters #Tells what letters the guy has missed
if word==c:
print "You Win!"
sys.exit()
else:
guess(count,addCount,letters) #repeats until win or lose
else:
if choice in letters:
print "You have already guessed this!" #so he/she doesn't repeat a stupid mistake
guess(count,addCount,letters)
count+=addCount
letters[count]=choice
if count==0:
print "O"
addCount=1
elif count==1:
print "O<"
addCount=2
elif count==2:
print "0<-"
addCount=3
elif count==3:
print "O<-<\n Game Over XP"
sys.exit()
print "Letters missed: ", ' '.join(letters)
guess(count,addCount,letters)
def indexList(s, item, i=0):
i_list = []
while True:
try:
i = s.index(item, i)
i_list.append(i)
i += 1
except:
break
return i_list
if __name__=='__main__':
word=raw_input("Type a name:")
word=''.join(word.lower().split(' '))
#print word #This was just for testing
line=['_ ']*len(word)
print ''.join(line)
count=0 #set count
addCount=0 #set add count
letters=['']*4 #make an empty list
guess(count,addCount,letters) #carries everything to guess for later use
import sys # used to exit
def guess(count,addCount,letters):
choice=raw_input("Guess!(lowercase only please!)")
aList=indexList(word, choice)
print aList
if len(choice)>1:
print "Don't cheat!" # Exactly :)
guess(count,addCount,letters)
elif len(aList) > 0:
for i in aList:
line[i] = choice #Problem here. aList is list when needs to be integers
print "Good Choice!"
c=''.join(line)
print c,"Letters missed:", letters #Tells what letters the guy has missed
if word==c:
print "You Win!"
sys.exit()
else:
guess(count,addCount,letters) #repeats until win or lose
else:
if choice in letters:
print "You have already guessed this!" #so he/she doesn't repeat a stupid mistake
guess(count,addCount,letters)
count+=addCount
letters[count]=choice
if count==0:
print "O"
addCount=1
elif count==1:
print "O<"
addCount=2
elif count==2:
print "0<-"
addCount=3
elif count==3:
print "O<-<\n Game Over XP"
sys.exit()
print "Letters missed: ", ' '.join(letters)
guess(count,addCount,letters)
def indexList(s, item, i=0):
i_list = []
while True:
try:
i = s.index(item, i)
i_list.append(i)
i += 1
except:
break
return i_list
if __name__=='__main__':
word=raw_input("Type a name:")
word=''.join(word.lower().split(' '))
#print word #This was just for testing
line=['_ ']*len(word)
print ''.join(line)
count=0 #set count
addCount=0 #set add count
letters=['']*4 #make an empty list
guess(count,addCount,letters) #carries everything to guess for later use
Comment