1 parent e745e75 commit 3812f50Copy full SHA for 3812f50
1 file changed
Ch2 - Basics/challenge_solution.py
@@ -3,7 +3,18 @@
3
#
4
5
def is_palindrome(teststr):
6
- # use the slice trick to reverse the string
+ # 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
18
if teststr == teststr[::-1]:
19
return True
20
return False
0 commit comments