LearnPy Hub
← File Handling problems
Hard

Read a Config File

Write the input lines (until END) to app.cfg. Each line is key = value; blank lines and lines starting with # are ignored. Read the file into a dictionary and print the keys and values sorted by key as key: value.

Input

Lines, then END.

Output

One line per setting.

Sample 1

Input
# settings
name = LearnPy

port = 8000
END
Output
name: LearnPy
port: 8000

Sample 2

Input
a=1
END
Output
a: 1
solution.py
Output appears here
Read a Config File · Python practice problem · LearnPy Hub