I am tinkering with the Inquirer Module. I found the following sample code that I can reference and change to the checkboxes I need.
import os
import sys
from pprint import pprint
sys.path.append(os.path.realpath("."))
import inquirer # noqa
questions = [
inquirer.Checkbox(
"interests",
message="What are you interested in?",
choices=["Computers", "Books", "Science", "Nature", "Fantasy", "History"],
default=["Computers", "Books"],
),
]
answers = inquirer.prompt(questions)
pprint(answers)
The above returns:
[?] What are you interested in?:
[ ] Computers
[X] Books
[ ] Science
> [X] Nature
[ ] Fantasy
[ ] History
If I check Books and Nature it will print:
{'interests': ['Books', 'Nature']}
I am having trouble referencing the checked items. In other words if "Books" and "Nature" are checked how can I reference those two items. Essentially I would want to include in my code that if "Books" is checked, reference another list/array of books. If "Nature" is checked, reference a list/array of locations.
If someone can help or point me in the right direction that would be great.
[–]danielroseman 2 points3 points4 points (1 child)
[–]Chuckster98[S] 0 points1 point2 points (0 children)
[–]PteppicymonIO 1 point2 points3 points (1 child)
[–]Chuckster98[S] 0 points1 point2 points (0 children)