'Obtaining name and value of choice list from input
I have a list with toppings and their prices. After the user selected the choice, I want to obtain the name of the topping and the price individually. However with dict.get()(in this case answers.get('name') for example, I don't obtain anything.
price=()
questions = [
{
'type': 'checkbox',
'message': 'Select toppings',
'value': price,
'name': 'toppings',
'choices': [
{
'name': 'Ham',
price: 4.35
},
{
'name': 'Ground Meat',
price: 2.50
},
]
answers = prompt(questions, style=style)
answers.get('name')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
