Python Flashcards

(2 cards)

1
Q

What is a dictionary in Python and how does it work?

A

A dictionary (dict) is like an object in JavaScript. It’s defined the same way. For example:

count = {}

This sort of object is a bit different though because its largely like a map. A JavaScript object “coerces” any key to a string whereas the key in a dictionary can be any value. So the boolean “true” could map to a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly