Select to view content in your preferred language

Python List to Variables.

235
1
Jump to solution
08-01-2024 09:04 AM
kapalczynski
Frequent Contributor

I query for a list of replicas and am getting this back... 

replica_list = aah_flc.replicas.get_list()
print(replica_list)
for r in replica_list:
    print(r)

RESULT:
[{'replicaName': 'TESTRepli_1722367918746', 'replicaID': '954xxxxx-FDE4-4DD7-AF63-E5C8D3A5543C'}, {'replicaName': 'TESTRepli_1722367839142', 'replicaID': '2DF44EEC-ADC4-4C4E-8F36-DBxxxxx7D7'}]

{'replicaName': 'TESTRepli_1722367918746', 'replicaID': '954xxxxx-FDE4-4DD7-AF63-E5C8D3A5543C'}

{'replicaName': 'TESTRepli_1722367839142', 'replicaID': '2DF44EEC-ADC4-4C4E-8F36-DBxxxxx7D7'}

 

I am looking for how to loop through this and write each replicaID to a variable... 

Instead of print(r) I was trying to grab JUST the replicaID but not successful

print(r[0]['replicaID'])

Any thoughts on how to return just the 'replicaID' so I can assign it to a variable to do other things with it like unregister the replica

0 Kudos
1 Solution

Accepted Solutions
kapalczynski
Frequent Contributor

never mind got it with this

print(r['replicaID'])

View solution in original post

1 Reply
kapalczynski
Frequent Contributor

never mind got it with this

print(r['replicaID'])