Computer Science, asked by Ishan009, 6 months ago

Write a Python function that returns True if aString is a palindrome (reads the same forwards or reversed) and False otherwise. Do not use Python's built-in reverse function or aString[::-1] to reverse strings. This function takes in a string and returns a boolean. def isPalindrome(aString): ''' aString: a string ''' # Your code here

Answers

Answered by disilvaprince
0

Explanation:

def isPalindrome(s):

return s == s[::-1]

# Driver code

s = "malayalam"

ans = isPalindrome(s)

if ans:

print("Yes")

else:

print("No")

give a like and follow on insta for more codings

@__princely___

Answered by pragyakirti12345
0

Answer: Python program is given below

Concept : Python program

Given : This function takes in a string and returns a boolean.

To Find : Write a Python function that returns True if a String is a

               palindrome (reads the same forwards or reversed) and False

               otherwise.

Explanation:

Python is a high level, interpreted, object oriented programming language. Python is highly readable, English like language. Its syntax is easy to understand and write. It has many pre defined methods which makes this language interactive and beginners friendly. Python is a functional and structural programming language, and it supports dynamic type checking also.

# Code is written below

def isPalindrome( aString):

   # Running loop from 0 to length/2

   for i in range(0, int(len(aString)/2)):

       if aString[i] != aString[len(str)-i-1]:

           return False

   return True

# main function which calls the user defined function

p = input()    #taking user input

result = isPalindrome(p)

if (result):

   print("True")

else:

   print("False")

#SPJ3

Similar questions