This topic is READ ONLY
Bennjamin (27) [Avatar] Offline
#1
i tried this program:
while 1:
words = []
defs = []
for i in range(1, 11):
words.append(raw_input('Type in word #%s, please.'%i))
defs.append(raw_input('Type in its definition.'))
dictionary = {
words[0] : defs[0],
words[1] : defs[1],
words[2] : defs[2],
words[3] : defs[3],
words[4] : defs[4],
words[5] : defs[5],
words[6] : defs[6],
words[7] : defs[7],
words[8] : defs[8],
words[9] : defs[9],
}
try:
for j in range(0, 10):
print str(dictionary.items()[j][1]) + str(dictionary.items()[j][2][1])
break
except IndexError:
print "All words and defs must be different. please try again."
but it seems that even when all the words and definitions i type in are different, it still gives an indexerror and restarts the program... am i doing something wrong??? please help :'(
P.S. the iteration variable would've been "i", but when you put that in [] brackets, it takes it as an italics starting tag, which is kind of sad.