New groups

Report a typo

A kindergarten in Berlin is organizing children into groups. The available group names are stored in a list:

groups = ['1A', '1B', '1C', '2A', '2B', '2C', '3A', '3B', '3C']

Your task is to create a dictionary that represents the allocation of children to these groups. Here's what you need to do:

  1. Read an integer input representing the number of groups to be filled.

  2. Subsequent lines are the number of children in each group, listed in the same order as the groups list variable.

  3. Create a dictionary where:

    • The keys are all the group names from the groups list.

    • The values are:

      • The number of children for filled groups

      • None for any groups that remain unfilled

  4. Print the resulting dictionary.

Notes:

  • All nine groups should be included in the dictionary, even if they're not all filled.

  • The groups are filled in order, starting from '1A' and moving through the list.

  • If there are fewer filled groups than the total number of groups, the remaining groups should have a value of None.

Sample Input 1:

4
10
12
9
10

Sample Output 1:

{'1A': 10, '1B': 12, '1C': 9, '2A': 10, '2B': None, '2C': None, '3A': None, '3B': None, '3C': None}
Write a program in Python 3
# the list with classes; please, do not modify it
groups = ['1A', '1B', '1C', '2A', '2B', '2C', '3A', '3B', '3C']

# your code here
___

Create a free account to access the full topic