Home »
Python »
Python Dictionary MCQs
How will you add these items to the already created empty dictionary? Suppose I want to have the following output:
17. How will you add these items to the already created empty dictionary? Suppose I want to have the following output:
{0: 'welcome', 2: 'to', 3: 'include help'}
- Dict[0] = 'welcome'
Dict[2] = 'to'
- Dict[3] = 'include help'
[0] = 'welcome'
[2] = 'to'
[3] = 'include help'
- Dict[0] = [0:'welcome']
Dict[1] = [2:'to']
Dict[2] =[3: 'include help']
Answer: A) Dict[0] = 'welcome'
Dict[2] = 'to'
Explanation:
Option A would be the correct syntax to add the elements.