Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Iterate a tuple with dict inside
My output is below, its tuple inside dict, help iterate

for interface in result["interfaces"].items():

('Eth-Trunk1.1908', {'description': 'EXT/ILL/830400/KAVERI INFORMATICS PRIVATE LIMITED/12005830400/NOIDA/2MB/P2M/3333', 'qos-profile': '2Mb', 'vlan-type': '1908', 'address': '', 'netmask': '', 'network': ''}) ('Eth-Trunk1.1909', {'description': 'EXT/ILL/830166/KOMMLABS DEZIGN PRIVATE LIMITED/12005830166/NOIDA/10MB/P2M/3333', 'qos-profile': '10Mb', 'vlan-type': '1909', 'address': '', 'netmask': '', 'network': ''}) ('Eth-Trunk1.1910', {'description': 'EXT/ILL/828573/ROHA HOUSING FINANCE PRIVATE LIMITED/12005828573/P2M/10MBPS/3333', 'qos-profile': '10Mb', 'vlan-type': '1910', 'address': '', 'netmask': '', 'network': ''}) ('Eth-Trunk1.1911', {'description': 'EXT/ILL/829997/RASTRA NIRMAN/12005829997/NOIDA/10MB/P2M/3333', 'qos-profile': '10Mb', 'vlan-type': '1911', 'address': '', 'netmask': '', 'network': ''}) ('Eth-Trunk1.1912', {'description': 'EXT/ILL/829765/SANGEET AUDIO INDIA PRIVATE LIMITED/12005829765/NOIDA/20MB/P2M/3333', 'qos-profile': '20Mb', 'vlan-type': '1912', 'address': '', 'netmask': '', 'network': ''})
I want to print tuple values and dictionary values.


Eth-Trunk1.1908 EXT/ILL/830400/KAVERI INFORMATICS PRIVATE LIMITED/12005830400/NOIDA/2MB/P2M/3333 2Mb 1908
Larz60+ wrote Feb-13-2019, 10:12 AM:
You've been on the forum long enough to use proper BBcode tags.
more than one line of code, use python, not icode tags.
This should do the trick.

for interface in result["interfaces"].items():
    print(interface[0], " ".join(interface[1].values()))
Thanks, worked for me.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Being explicit about the items inside a tuple argument rudihammad 3 177 Dec-04-2019, 08:10 AM
Last Post: perfringo
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 422 May-21-2019, 11:39 AM
Last Post: avorane
  return dict in tuple bb8 6 1,097 Feb-26-2018, 08:16 PM
Last Post: bb8

Forum Jump:

Users browsing this thread: 1 Guest(s)