What is the correct way to create a dictionary in Python?
Correct answer
A. dict = {"key1": "value1", "key2": "value2"}
15 views
A. dict = {"key1": "value1", "key2": "value2"}
15 views
dict = {"key1": "value1", "key2": "value2"} is correct: dictionaries use curly braces, with each key separated from its value by a colon and pairs separated by commas.
Parentheses create tuples and square brackets create lists, so the same content inside them is a syntax error.
Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.