I have a for loop that generates strings associated with the number in the numbers list by searching through an XML file.
tree = parse("demo.xml")
root = tree.getroot()
fields = {int(child.attrib["number"]): child.attrib["name"] for child in root}
numbers [1, 4, 5, 8, 9, 45, 78]
for number in numbers:
print(fields.get(number, f"{number} does not exist in XML"))
so the output is like:
Account
Name
ID
Time
I want to save this output to a list, and separate each text by a comma, so it should save this to a list that should look like:
myList: [Account, Name, ID, Time]
How can I do this?