0

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())
Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56
Alex Hawking
  • 1,125
  • 5
  • 19
  • 35

2 Answers2

1

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])
Óscar López
  • 232,561
  • 37
  • 312
  • 386
1

Assuming you have result in dict named "result" as below

result = {'Apps': ['Notes']}

You can directly get it as

result['Apps'][0]
Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56
Shirish Goyal
  • 510
  • 2
  • 9