Logo

Programming-Idioms

History of Idiom 118 > diff from v64 to v65

Edit summary for version 65 by programming-idioms.org:
[Python] Better demo link (shows code)

Version 64

2021-10-12, 05:43:46

Version 65

2022-02-24, 18:09:04

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Turning the list [a,b,c,b] into the set {c,a,b}

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Turning the list [a,b,c,b] into the set {c,a,b}
Variables
y,x
Variables
y,x
Code
y = set(x)
Code
y = set(x)
Doc URL
https://docs.python.org/3/library/stdtypes.html#set
Doc URL
https://docs.python.org/3/library/stdtypes.html#set
Demo URL
https://repl.it/@ProgIdioms/TediousStaleNamebinding
Demo URL
https://replit.com/@ProgIdioms/TediousStaleNamebinding#main.py