I am trying to make my function locate duplicate words and if so the output should be True or False depending on wether there are duplicate words. For example:
doubleWord("cat") --> False .
doubleWord("catcat") --> True .
doubleWord("contour" * 2) --> True
So far I have this:
def main():
word = input("Enter a string: ")
half = len(word) >> 1
if word[:half] == word[half:]:
print("True")
else:
print("False")
return
print(main())
if name == "main": main()
Any help would be greatly appreciated. I thought maybe using slicing would make it easier but I have no idea how to implement that in my code. Thanks!
"catcat"should returnTrue. But in your code you're splitting the input where there's a space, so"catcat"would be considered a single word.