-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpful_methods.py
More file actions
25 lines (25 loc) · 1016 Bytes
/
Copy pathhelpful_methods.py
File metadata and controls
25 lines (25 loc) · 1016 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
def print_max_five(some_literal):
counter = 0
if type(some_literal) == list:
for i in some_literal:
counter += 1
if counter % 5 == 0 and not i == some_literal[-1]:
print(i + ",")
elif not i == some_literal[-1]:
print((i + ", "), end = '')
else:
print(i)
elif type(some_literal) == dict:
for key in some_literal:
counter += 1
if counter % 5 == 0 and not key == list(some_literal.keys())[-1]:
print((key + ": "), end = '')
print("{:.2f}".format(some_literal[key]), end = '')
print((","))
elif not key == list(some_literal.keys())[-1]:
print((key + ": "), end = '')
print("{:.2f}".format(some_literal[key]), end = '')
print((", "), end = '')
else:
print((key + ": "), end = '')
print("{:.2f}".format(some_literal[key]))