Search code examples
pythonlisttuples

Print 1 item from returned tuple or list data


I am fairly new to python and am working on a project that uses rest protocol to retrieve data from a device(robot). I am trying to break the data down from a huge list so that I can get a specific value out of it. Here is my code:

getMissionQueue = robot.get_mission_queue()[1][0]
    print(getMissionQueue)

At this point, "getMissionQueue" will print

{u'state': u'Executing', u'id': 1286}

The value that I am trying to get as a stand alone variable is 1286. I tried doing this but it is only returning string values:

for item in getMissionQueue:
        print (item)

Any help would be appreciated, thanks!


Solution

  • You'll find what you're looking for with getMissionQueue['id']. This explains the issue with your for loop!