Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions