Skip to content

Commit 8ecb802

Browse files
Merge pull request #2678 from LAbhilashKumar/fixing_palindrome_issue
Fixing palindrome issue
2 parents c81a961 + 9ed1c4b commit 8ecb802

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

string_palin.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
3+
# With slicing -> Reverses the string using string[::-1]
4+
5+
6+
string= input("enter a word to check.. ")
7+
copy=string[::-1]
8+
if string == copy:
9+
print("Plaindrome")
10+
else:
11+
print("!")
12+
13+
# Without slicing –> Reverses the string manually using a loop
14+
reverse_string=""
15+
for i in string:
16+
reverse_string=i+reverse_string
17+
if string == reverse_string:
18+
print(reverse_string)
19+
else:
20+
print("!")

0 commit comments

Comments
 (0)