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 "", line 1, in

NameError: name 'hello' is not defined

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!