The code:
count = 0
oldcount = 0
for char in inwords:
if char == " ":
anagramlist.append(inwords[oldcount, count])
oldcount = count
count = 0
else:
count += 1
the error:
Traceback (most recent call last):
File "C:/Users/Knowhaw/Desktop/Python Programs/Anagram solver/HTS anagram.py", line 14,
in <module>
anagramlist.append(inwords[oldcount, count])
TypeError: string indices must be integers
what the hell is going on?
count and oldcount are obviously ints, yet the error says they aren’t
I can even write
anagramlist.append(inwords[int(oldcount), int(count)])
and get the same error
You’re trying to use
(oldcount, count)as an index to the list. This is a tuple, not an int.Do you perhaps mean:
?