Write a python function to check if a given string is symmetrical


Topic: Write a python function to check if a given string is symmetrical

Solution

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
       
    return flag



List all Python Programs