forked from fenyx-it-academy/Class4-PythonModule-Week3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathequal_reverse
More file actions
19 lines (18 loc) · 766 Bytes
/
equal_reverse
File metadata and controls
19 lines (18 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 5-equal_reverse.py
# Write a function that controls the given inputs wheter they are equal with their reverse writing or not.
# Input >>> madam, tacocat, utrecht
# Output >>> True, True, False
def equal_reverse ():
word=input("Type some words separately: ")
word_list=list(word.split(" "))
result_list=[]
for i in word_list:
if len(i)%2==0 and i[:int(len(i)/2)][::-1]==i[int(len(i)/2):]:
print("True")
elif len(i)%2==0 and i[:int(len(i)/2)][::-1]!=i[int(len(i)/2):]:
print("False")
elif len(i)%2==1 and i[:int(len(i)//2)][::-1]==i[int(len(i)//2)+1:]:
print("True")
elif len(i)%2==1 and i[:int(len(i)//2)][::-1]!=i[int(len(i)//2)+1:]:
print("False")
equal_reverse()