Mar-09-2022, 06:52 PM
(This post was last modified: Mar-09-2022, 11:28 PM by Yoriz.
Edit Reason: Added code tags
)
I have this command with this output below. I want to put output values in a new variable LIST so could check for later if on that list there is a word HardDisk.
I think I found it :
>>> import xml.etree.ElementTree as ET
>>> xml_to_parse1 = ET.parse('/tmp/xmlfile.xml')
>>> get_xml = xml_to_parse1.getroot()
>>> all_kind_of_disks = []
>>> g_unique = set()
>>> for x in get_xml.findall('physicaldisk'):
... diskType =x.find('diskType').text
... #diskType = list(dict.fromkeys(diskType))
... g_unique.add(diskType)
... #print(diskType)
...
>>> for x in g_unique:
... print(x)
...
FlashDisk
M2Disk
HardDisk
PMEM
>>>I think I found it :
>>> distinct_values = [] >>> >>> for x in g_unique: ... distinct_values.append(x) ... print(x)
