Skip to content

Commit 3812f50

Browse files
committed
Update the palindrome challenge
1 parent e745e75 commit 3812f50

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Ch2 - Basics/challenge_solution.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
#
44

55
def is_palindrome(teststr):
6-
# use the slice trick to reverse the string
6+
# one way to do it: calculate the reverse of the string
7+
# reversestr = ""
8+
# strindx = len(teststr)-1
9+
# while (strindx >= 0):
10+
# reversestr += teststr[strindx]
11+
# strindx -= 1
12+
13+
# if teststr == reversestr:
14+
# return True
15+
# return False
16+
17+
# more advanced: use the slice trick to reverse the string
718
if teststr == teststr[::-1]:
819
return True
920
return False

0 commit comments

Comments
 (0)