I would like to create a user input for a function of mine. So this function of mine is a boolean function. It is used to test whether a word is a palindrome or not by giving an output True or False.
I want to create a separate function (user input) where a person can type in the phrase that they want to find out if its a palindrome or not and it should print out the words "The phrase you entered, XXXXXX is a palindrome" when output is true and when output is false it should go "The phrase you entered, XXXXXX is not a palindrome".
My code as below:
def palindrome(phrase):
len_phrase = len(phrase)//2
print("len_phrase",len_phrase)
for i in range(len_phrase):
print(phrase[i],phrase[-i-1])
if phrase[i] != phrase[-i-1]:
return False
return True
inputfunction. w3schools.com/python/ref_func_input.aspis_palindrome, that would be more readable and explicit (see The Zen of Python,import this).