Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # no dictionary
- numbers_sequence = list(map(int, input().split(", ")))
- max_group = max(numbers_sequence) // 10 + 1
- if max(numbers_sequence) % 10 == 0:
- max_group -= 1
- current_group = 0
- for groups in range(max_group):
- group_list = [number for number in numbers_sequence if current_group < number <= (current_group + 10)]
- current_group += 10
- print(f"Group of {current_group}'s: {group_list}")
- group_list.clear()
- #with_dictionary
- list_numbers = [int(x) for x in input().split(", ")]
- sorted_groups = {}
- group = 0
- while True:
- if not list_numbers:
- break
- if max(list_numbers) > group:
- group += 10
- sorted_groups[group] = [num for num in list_numbers if num <= group]
- list_numbers = [x for x in list_numbers if x > group]
- for key, value in sorted_groups.items():
- print(f"Group of {key}'s: {value}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement