Skip to content

Commit b337c6a

Browse files
Merge pull request geekcomputers#342 from christianbender/improved_Palindrome_Checker
Palindrome_Checker.py : Improved palindrome checker
2 parents 02868dd + 18a34ec commit b337c6a

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Palindrome_Checker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
else:
1515
phrase = givenPhrase
1616

17-
string = "".join(char.lower() for char in phrase if char.isalnum())
18-
reversedString = "".join(reversed(string))
17+
string = phrase.lower()
1918

20-
if string == reversedString:
19+
if string == string[::-1]:
2120
print("\nWow!, The phrase is a Palindrome!")
2221
else:
2322
print("\nSorry, The given phrase is not a Palindrome.")

0 commit comments

Comments
 (0)