I'm trying to create a function in python does specific functions with a list of words in a text document. All the other functions work so it is not a problem with the word document. This function i'm trying to create looks through each word on a word document and tells if there is two of the same letter next to each other in it. It always says there is 0 letters touching in the document.
I've tried this but just cannot for the life of me see why it is not working, at the part of
if word[a] == word[a+1:]: the variable a is 0, when it should be a letter of the word
def sameLettersTouchingFn(wordDocument):
sameLettersTouchingCount = 0
for word in wordDocument:
for a in range(len(word)-1): #for every letter in the word
if word[a] == word[a+1:]: #if letter is same as one next to it
sameLettersTouchingCount +=1 # count goes plus one
if sameLettersTouchingCount == 1: # if it has two letters touching
print(word, "Has two of the same letter touching") #prints it has two letters touching
print ("There is", sameLettersTouchingCount, "words with letters touching")
My expected results is it to print the words with the same letter touching in it and print how many words have the same letter touching. It doesn't say any words have the same letter touching and says 0 words have the same letters touching