Python · Dictionaries & Sets

Do sets keep insertion order like dicts? Why might {'A', 'B', 'C'} print in a different order across separate runs?

Answer locked. Get the free KnowCard app to reveal it — plus spaced-repetition review so it actually sticks.

Get it on App StoreGet it on Google Play

This is one card from the KnowCard library — thousands more across SAP, Linux, Python and more. In the app you get the answer, AI explanations, and cards that come back right before you would forget them. Free to start on iOS, Android or the web.

More in Dictionaries & Sets

What does this print? ``` d = {"a": 1, "a": 2} print(d) ```
Why does this raise an error? ``` d = {[1, 2]: "x"} ```
Can a tuple be a dict key but a list cannot? Why the difference?
What does this print? ``` d = {1: "x"} print(d[1.0]) ```
What does this print? ``` d = {"a": 1, "b": 2} print("a" in d) print(1 in d) ```
What does this loop print? ``` d = {"a": 1, "b": 2} for x in d: print(x) ```

Start learning today

Free to start — download the app or use it in your browser.

Get it on App StoreGet it on Google Play