pythonpython-3.xinquirer

Python Print Parts Of Dictionaries


I'm writing some python using the module inquirer and it returns the results as a python dictionary, like this:

{'Apps': ['Notes']}

I was wondering if would be possible to just get the 'Notes' bit somehow? The code for the selection thing is below but I don't think it is relevant.

import os
import inquirer

def app_menu():
    selections = [inquirer.Checkbox('Apps',
                  message='Please select you app',
                  choices=['Weather', 'Notes', 'Calculator', 'Exit'])]

    app_sel = inquirer.prompt(selections)
    print(app_sel.values())

Solution

  • Try this:

    print(app_sel['Apps'])
    

    Or this, if you're sure that there's only one element in the list:

    print(app_sel['Apps'][0])