Is there a way to split the text of each input in an array to words with a separator? Example Input
tag_attribute = ['Content_ExportDate','Controller_SoftwareRevision','DataType_Owner']
With the separator as '_', the expected printed result:
Tag: Content
Attribute: Exportdate
Tag: Controller
Attribute: SoftwareRevision
Tag: DataType
Attribute: Owner
The '_' is just an example I can think of for a separator, but I can work with any of other symbols. I just need to find a way to have the input in an array as two separate inputs
CodePudding user response:
You can use this example it will generate you the output that you want
for tag, att in [x.split("_") for x in tag_attribute]:
print(f"Tag: {tag}")
print(f"Attribute: {att}")