Skip to content

Commit 3f87c72

Browse files
authored
Create unit5_ex5.3.4.py
1 parent b2e9375 commit 3f87c72

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

unit5_ex5.3.4.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# exercise 5.3.4 from unit 5
2+
'''
3+
The function accepts as a string parameter. The function returns true if the last character that appears in the string also appears before. Otherwise the function returns false.
4+
5+
Guidelines
6+
Uppercase or lowercase letters are not important.
7+
'''
8+
9+
def last_early(my_str):
10+
my_str = my_str.lower()
11+
12+
last_char = my_str[-1]
13+
14+
return last_char in my_str[:-1]
15+
16+
print(last_early("happy birthday")) # True
17+
18+
print(last_early("best of luck")) # False
19+
20+
print(last_early("Wow")) # True
21+
22+
print(last_early("X")) # False
23+
24+
25+
26+

0 commit comments

Comments
 (0)