-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (42 loc) · 1.18 KB
/
main.py
File metadata and controls
54 lines (42 loc) · 1.18 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
49
50
51
52
53
54
# Resolve the problem!!
PALINDROMES = [
'Acaso hubo buhos aca',
'A la catalana banal atacala',
'Amar da drama',
]
NOT_PALINDROMES = [
'Hola como estas',
'Platzi'
'Oscar',
]
def is_palindrome(palindrome):
# Start coding here
palindrome = palindrome.lower()
palindrome = palindrome.strip()
palindrome = palindrome.replace(' ', '')
palindrome = palindrome.replace('á', 'a')
palindrome = palindrome.replace('é', 'e')
palindrome = palindrome.replace('í', 'ó')
palindrome = palindrome.replace('ó', 'o')
palindrome = palindrome.replace('ú', 'u')
palindrome = palindrome.replace('ü', 'u')
palindrome = palindrome.replace(',', '')
if palindrome == palindrome[::-1]:
return True
else:
return False
def validate():
for palindrome in PALINDROMES:
if not is_palindrome(palindrome):
return False
for not_palindrome in NOT_PALINDROMES:
if is_palindrome(not_palindrome):
return False
return True
def run():
if validate():
print('Completaste el test')
else:
print('No completaste el test')
if __name__ == '__main__':
run()