get_unique_items_in_a_list
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
get_unique_items_in_a_list [2021/07/23 21:54] – [Task] raju | get_unique_items_in_a_list [2021/07/23 22:14] (current) – [Notes and assumptions] raju | ||
---|---|---|---|
Line 5: | Line 5: | ||
mylist = [' | mylist = [' | ||
</ | </ | ||
- | get the list of unique items. | + | get the list of unique items. |
- Order does not matter. < | - Order does not matter. < | ||
[' | [' | ||
</ | </ | ||
- | - Preserve the order and keep the first unique | + | - Preserve the order and keep the first unique |
[' | [' | ||
</ | </ | ||
- | - Preserve the order and keep the last unique | + | - Preserve the order and keep the last unique |
[' | [' | ||
</ | </ | ||
- | Assume Python >= 3.9 is used | + | ==== Notes and assumptions ==== |
+ | * Starting from Python 3.7, dictionaries in python are ordered by insertion order. Per https:// | ||
+ | Performing list(d) on a dictionary returns a list of all the keys used in the dictionary, in insertion order | ||
+ | </ | ||
+ | * Assume Python >= 3.7 is used. | ||
==== Case 1: unique unordered ==== | ==== Case 1: unique unordered ==== |
get_unique_items_in_a_list.1627077267.txt.gz · Last modified: 2021/07/23 21:54 by raju