# Analyzing and testing a program with binary search method
def isPal(x):
assert type(x)==list
temp=x # Third bug, unsafe use for assignment of the list, Solution: try 'temp=x[:]' to copy 'x' list to 'temp' safely
#print(temp,x) # Fourth use of print, try to see what 'temp' and 'x' lists shows before and after reversion
temp.reverse # -> Second bug, Solution: temp.reverse()
#print(temp,x) # Third use of print, searching another potential bug on the upper half of the function
if temp==x:
return True
else:
return False
def silly(n):
#result=[] -> Solution for the first bug, place it outside of the loop
for i in range(n):
result=[] # -> First bug, causing the 'result' list to be empty list each time in the loop
elem=raw_input('Enter element: ')
result.append(elem)
#print(result) -> Second use of print, to see the 'result' more detailed within the 'for' loop
#print(result) -> First use of print, searching the potential bug on the upper half of the code
if isPal(result): #Make sure the upper half of the code dosen't include any bugs, then search other bugs in other half
print('Yes')
else:
print('No')
# k,a,y,a,k m,a,k,a,m / z,a,m,a,n
# Try palindrome and non-palindrome sequences for testing the 'silly' function
silly(5)