Skip to content

Commit dc45a1d

Browse files
anoosragh69techyminati
authored andcommitted
String palindrome
1 parent 002f788 commit dc45a1d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Hacktober2023/string_palidrome.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def palindrome(n):
2+
n=n.lower()
3+
l=len(n)
4+
mid=l//2
5+
rev=-1
6+
for i in range(mid):
7+
if n[i]==n[rev]:
8+
rev-=1
9+
else:
10+
print(n,'is not a palindrome')
11+
break
12+
else:
13+
print(n,'is a palindrome')
14+
s=input('Enter string: ')
15+
palindrome(s)

0 commit comments

Comments
 (0)