Question: Consider the following function definition: def isPal(myStr): myStr is a string. Returns True if myStr is forms a palindrom, False otherwise temp =

Consider the following function definition:

def isPal(myStr): """ myStr is a string. Returns True if myStr is forms a palindrom, False otherwise """ temp = myStr temp.reverse if temp == myStr: return True else: return False print(isPal('anna')) This function contains several bugs. When we first call print(isPal('anna')) we get the following error message: AttributeError: 'str' object has no attribute 'reverse'

Select how to modify the code so that this error only does not occur (do not pick the solutions that fix other bugs).

a. Insert at the beginning of the block of code: myStr = list(myStr)

b. Replace temp = myStr by temp = myStr[:]

c. Replace if temp == myStr: by if temp == list(myStr):

d.

Replace temp.reverse by temp.reverse()

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!