-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9.2 Lab #6.py
More file actions
48 lines (38 loc) · 1.02 KB
/
9.2 Lab #6.py
File metadata and controls
48 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
#Question 1
def longestValue (string):
newString = ""
startingoff = ""
for i in string:
if i>startingoff:
newString += i
startingoff = i
return newString
# print(longestValue("abcdefgzab"))
#Question 2
def is_Palindrome (string):
string = string.lower()
counter = -1
for i in string:
if i != " ":
if i == string[counter]:
counter -= 1
if counter < (0-len(string)):
counter = (0-len(string))
else:
return False
if string[counter] == " ":
counter -= 1
return True
# print(is_Palindrome("Are we not drawn onward, we few, drawn onward to new era"))
#Question 3
def PreProcess (string):
string = string.lower()
realString = ""
for i in string:
if i.isalnum():
realString += i
return realString
phrase=input("Please enter a phrase: ")
new_phrase=PreProcess(phrase)
print(is_Palindrome(new_phrase))