Skip to content

Commit 8f0791f

Browse files
committed
p31
1 parent 1a901b0 commit 8f0791f

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

15-palindrome.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
def PalindromeTwo(str):
2-
str = "".join(i.lower() for i in str if i.isalpha())
1+
def Palindrome(str):
2+
str = str.replace(" ", "")
33
return "true" if str == str[::-1] else "false"
4-
4+
5+
56
# keep this function call here
67
# to see how to enter arguments in Python scroll down
7-
print PalindromeTwo(raw_input())
8+
print Palindrome(raw_input())
89

910

10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20-
21-
22-
23-
24-

31-palindrone-two.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Have the function PalindromeTwo(str) take the str parameter being passed and return the string true if the parameter is a palindrome, (the string is the same forward as it is backward) otherwise return the string false. The parameter entered may have punctuation and symbols but they should not affect whether the string is in fact a palindrome. For example: "Anne, I vote more cars race Rome-to-Vienna" should return true.
2+
3+
# Use the Parameter Testing feature in the box below to test your code with different arguments..
4+
5+
def PalindromeTwo(str):
6+
str = "".join(i.lower() for i in str if i.isalpha())
7+
return "true" if str == str[::-1] else "false"
8+
9+
# keep this function call here
10+
# to see how to enter arguments in Python scroll down
11+
print PalindromeTwo(raw_input())
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+

0 commit comments

Comments
 (0)