And we can apply arithmetic operations on it. Here are some examples.
Here is one example, testing a string is palindrome or not:
class Solution:
def is_palindrome(self, x1):
bool1=1
list1=list(x1)
for i in range(int(len(list1)/2)):
bool1=bool(list1[i]==list1[len(list1)-1-i])*bool1
if bool1==1:
return('True')
else:
return('False')
kk=Solution()
print(kk.is_palindrome('aba'))
Results:
True
No comments:
Post a Comment