LearnPy Hub
← Regular Expressions problems
Hard

Fill a Template

Read n lines of key=value, then a template line with placeholders like {{name}} (spaces inside the braces are allowed: {{ name }}). Replace each placeholder whose key is known with its value using re.sub with a function; leave unknown placeholders unchanged. Then print how many placeholders were left unfilled.

Input

n, the pairs, then the template.

Output

Two lines.

Sample 1

Input
2
name=Mim
course=Python
Hi {{name}}, welcome to {{ course }}!
Output
Hi Mim, welcome to Python!
0

Sample 2

Input
0
{{x}} and {{y}}
Output
{{x}} and {{y}}
2
solution.py
Output appears here
Fill a Template · Python practice problem · LearnPy Hub