代码拉取完成,页面将自动刷新
def palindrome(a):
mid = (len(a)-1)//2
start = 0
last = len(a)-1
flag = 0
while(start<mid):
if (a[start]== a[last]):
start += 1
last -= 1
else:
flag = 1
break;
if flag == 0:
print("The entered string is palindrome")
else:
print("The entered string is not palindrome")
def symmetry(a):
n = len(a)
flag = 0
if n%2:
mid = n//2 +1
else:
mid = n//2
start1 = 0
start2 = mid
while(start1 < mid and start2 < n):
if (a[start1]== a[start2]):
start1 = start1 + 1
start2 = start2 + 1
else:
flag = 1
break
if flag == 0:
print("The entered string is symmetrical")
else:
print("The entered string is not symmetrical")
string = 'amaama'
palindrome(string)
symmetry(string)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。