Skip to content

Commit

Permalink
Create Palindrome.py
Browse files Browse the repository at this point in the history
  • Loading branch information
archielicious committed Oct 20, 2022
1 parent 1b8f367 commit a546ff8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Program to find if a string is a palindrome or not
def palindrome():
word=input('Enter a string')
if len(word)==1:
print(word,'is a palindrome')
elif len(word)%2==0:
for n in range(0,int(len(word)/2)):
if word[n]==word[len(word)-(n+1)]:
if not n==int(len(word)/2)-1:
continue
print(word,'is a palindrome')
else:
print(word,'is not a palindrome')
break
elif len(word)%2!=0:
for n in range(0,int((len(word)/2)-0.5)):
if word[n]==word[len(word)-(n+1)]:
if not n==int((len(word)/2)-0.5)-1:
continue
print(word,'is a palindrome')
else:
print(word,'is not a palindrome')
break

0 comments on commit a546ff8

Please sign in to comment.