Tech Study

Write a Python function that checks whether a passed string is palindrome or not

Introduction

Write a Python function that checks whether a passed string is palindrome or not. I have used python 3.7 compiler for debugging purpose.

def isPalindrome(string):
    left_pos = 0
    right_pos = len(string) - 1
 
    while right_pos >= left_pos:
        if not string[left_pos] == string[right_pos]:
            return False
        left_pos += 1
        right_pos -= 1
    return True
print(isPalindrome('12121'))

Result

Write a Python function that checks whether a passed string is palindrome or not
Write a Python function that checks whether a passed string is palindrome or not

TaggedWrite a Python function that checks whether a passed string is palindrome or not

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more