-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_15.py
More file actions
30 lines (23 loc) · 913 Bytes
/
Copy pathday_15.py
File metadata and controls
30 lines (23 loc) · 913 Bytes
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
# Day 15 : Same in Reverse
def same_in_reverse(word):
theWord = word.lower()
a,b = 'áéíóúü', 'aeiouu'
change = str.maketrans(a,b)
newWord = theWord.translate(change)
new = ''.join(filter(str.isalnum, newWord))
return new == new[::-1]
word_str = '¿Acaso hubo búhos acá?'
print(same_in_reverse(word_str))
print('-'*35)
# Extra Challenge: What’s My Age?
def your_age(student):
name = student.lower()
if name in names_age:
return f'Hi, {student.capitalize()}, you are {names_age[name]} years old.'
else:
age = int(input("Your name is not in the database, please enter your age to be added: "))
names_age[name] = age
return f'Hi, {student.capitalize()}, you are {names_age[name]} years old.'
names_age = {"jane": 23, "kerry": 45, "tim": 34, "peter": 27}
student_name = input("Enter your name: ")
print(your_age(student_name))