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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started