Workout #25: XML Generator

Abish Pius
Python Workout
Published in
Oct 11, 2021

Write a function, myxml, that allows you to create simple XML output. The output from the function will always be a string. The function can be invoked in a number of ways, as shown in table 6.3.

Table 6.3 Calling myxml

Call  |   Return valuemyxml('foo') |  <foo></foo>myxml('foo', 'bar') |  <foo>bar</foo>myxml('foo', 'bar', a=1, b=2, c=3) | <foo a="1" b="2" c="3">bar</foo>

TRY IT YOURSELF

ANSWER

https://colab.research.google.com/drive/1t5VcBTU5rBoz6em8Ma6za8Vfm3DafvQK?usp=sharing

--

--

Abish Pius
Python Workout

Data Science Professional, Python Enthusiast, turned LLM Engineer