# 2019 IUSB Programming Competition # Round 1 Problem 2 # Check if a string is a palindrome # Solution by Dana Vrajitoru # Uses Python 3.6.2 import string # Strips whitespaces and punctuation from a string and converts to lowercase def stripSpacePunct(text): result = "" for c in text: if not (c in string.punctuation) and not (c in string.whitespace): result = result + c.lower() return result # Checks if the string is a palindrome def isPalindrome(text): n = len(text) for i in range(int(n/2)): if text[i] != text[n-i-1]: return False return True # Testing the function if __name__ == '__main__': print("Enter a string:") str = input() if isPalindrome(stripSpacePunct(str)): print("yes") else: print("no")