Advanced functions and decorators · 8 / 15 Exercise Easy

Record with keyword arguments

Objective

Create a Python program with a function that receives any amount of keyword arguments using **kwargs.

Instructions

  • Read an integer n and then n lines with the format key=value. Store them in a dictionary (split each line with split("=", 1)).
  • Define def record(**data), which shows one key: value line for each item, in the order they arrived, and finally Fields: N.
  • Call the function unpacking the dictionary with record(**dictionary).
Input
3
name=Ana
city=Madrid
age=30
Output
name: Ana
city: Madrid
age: 30
Fields: 3

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise