Data Types - Dictionary Flashcards

1
Q

Can Dictionaries be sliced, and why?

A

No - Python is simply not programmed to support it

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

person = {“name”: “Alice”, “age”: 30}

Give 2 ways to remove “age” from this dictionary

A

del person[“age”]

person.pop(“age”)

.remove() is a method for Lists

Use person.pop(“age”, None) to return “None” rather than raising an error

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