In: Computer Science
Using Python provide the implementation of a function called
"isAdjacent" that accepts a string.
The function checks if two adjacent characters in the string are
the same; if they are the same, then return True otherwise return
False. The function should ignore case and check for
non-empty string. If it's an empty string, then return
the message 'Empty string'.
Sample runs:
print( isAdjacent('ApPle')) # True
print( isAdjacent('Python')) # False
print( isAdjacent('')) # Empty string
Thanks for the question. Below is the code you will be needing Let me know if you have any doubts or if you need anything to change. Thank You !! =========================================================================== def isAdjacent(word): if len(word)==0: return 'Empty string' lowercase_word=word.lower() # for loop that ranges from 0 to len of word -1 for i in range(len(lowercase_word)-1): # check the current index letter with the next letter # if both are same return True if lowercase_word[i]==lowercase_word[i+1]: return True # if its not true above return false return False print( isAdjacent('ApPle')) # True print( isAdjacent('Python')) # False print( isAdjacent('')) # Empty string
===================================================================
===================================================================