forked from dominict/pythonteachingcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP2M3[Omar][Idris].py
More file actions
32 lines (20 loc) · 851 Bytes
/
P2M3[Omar][Idris].py
File metadata and controls
32 lines (20 loc) · 851 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
31
32
# [] create poem mixer function, call the function with the provided test string
# [] test string: `Little fly, Thy summer’s play My thoughtless hand Has brushed away. Am not I A fly like thee? Or art not thou A man like me?`
def word_mixer(word_list):
word_list.sort()
new_list = []
while len(word_list) > 5:
word_list.pop(4)
new_list.append(word_list.pop(0))
new_list.append(word_list.pop(-1))
return new_list
poem = input("Welcome, Omar Idris Enter a saying or a poem: ")
word_list = poem.split()
poem_length = len(word_list)
for i in range(poem_length):
if len(word_list[i]) <= 3:
word_list[i] = word_list[i].lower()
elif len(word_list[i]) >= 7:
word_list[i] = word_list[i].upper()
mixed = word_mixer(word_list)
print(" ".join(mixed))