In deze opgave vertrekken we van een tekstuele configuratiestring waarin instellingen worden weergegeven zoals in deze voorbeelden:
- ("Host" localhost) ("Port" 5432)
- ("File Path" /home/user/file.txt) ("Disk Space" 500GB)
- ("Database Name" my_database) ("User" admin) ("Password" secret123)
Schrijf een functie config
die één parameter neemt: een configuratiestring.
Deze string voldoet aan (zie ook voorbeelden hierboven):
"
).De functie retourneert een Python-dictionary waarin:
Je mag ervan uitgaan dat:
>>> config('("Host" localhost) ("Port" 5432)') {'Host': 'localhost', 'Port': 5432} >>> config('("File Path" /home/user/file.txt) ("Disk Space" 500GB)') {'File Path': '/home/user/file.txt', 'Disk Space': '500GB'} >>> config('("Database Name" my_database) ("User" admin) ("Password" secret123)') {'Database Name': 'my_database', 'User': 'admin', 'Password': 'secret123'}