Skip to content

Commit

Permalink
check whether a string is palindrome (jainaman224#2402)
Browse files Browse the repository at this point in the history
* pallindrome string python

* Update and rename pallindrome_string.py to palindrome_string.py

Fixed Typo in file name

* Update palindrome_string.py
  • Loading branch information
raksha009 authored and Mrunal committed Apr 8, 2020
1 parent e93cc7b commit ed6906c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Palindrome/palindrome_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Python program to find whether a string is a palindrome or not

# Function to reverse a String
def reverse(str):

# Initialize variable
rev = ""

for i in range (len(str)-1, -1, -1):
rev = rev + str[i]
return rev


# --- main ---
string = raw_input(("Enter a string: ")) #User Input

a = reverse(string) #Function call

if(a == string): #Comparing the reversed String with original String
print("String entered is palindrome!")
else:
print("String entered is not a palindrome!")

'''
TEST CASES
Enter a string: affcffa
String entered is palindrome!
Enter a string: abbcd
String entered is not a palindrome!
'''

0 comments on commit ed6906c

Please sign in to comment.