Question: Help with python Unix def isPalindrome(str): for i in range(0, len(str)//2): if str[i] != str[len(str)-i-1]: return False return True str = input(Enter a string: )
Help with python Unix
def isPalindrome(str):
for i in range(0, len(str)//2):
if str[i] != str[len(str)-i-1]:
return False
return True
str = input("Enter a string: ") #problem if I enter str it works. before I changed the line s = str=(input("sentence:"))
if isPalindrome(str):
print("String is palindrome.")
else:
print("String is not palindrome") ################################### error coming in output
~$ python isPalindrome.py
Enter a string: hello
Traceback (most recent call last):
File "isPalindrome.py", line 6, in
str =(input("Enter a string: "))
File "
NameError: name 'hello' is not defined
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
