#C6176. Item Collector
Item Collector
Item Collector
You are given a string representing a list of item details separated by commas. Each item is described by three values: a name, a type, and a value (an integer). Your task is to parse the string and construct a collection (list/array) of dictionaries (or objects) where each dictionary contains the keys: 'name', 'type', and 'value'.
Note:
- The input string may contain extra spaces around the values. Trim them as needed.
- If the input is empty or null, return an empty list.
A conversion formula for the value can be represented in LaTeX as follows:
Read the input from standard input and output the result to standard output exactly in the format shown in the examples.
inputFormat
The input is read from standard input (stdin). It consists of a single line containing the item details in the format: "name, type, value, ...".
outputFormat
Output the resulting list (or array) of dictionaries (or objects) to standard output (stdout). The format must exactly match the examples, for instance: [{'name': 'Sword', 'type': 'Weapon', 'value': 300}, {'name': 'Shield', 'type': 'Armor', 'value': 150}]## sample
Sword, Weapon, 300, Shield, Armor, 150
[{'name': 'Sword', 'type': 'Weapon', 'value': 300}, {'name': 'Shield', 'type': 'Armor', 'value': 150}]