Can we change lists to sets?. What is the main difference between them? | Sololearn: Learn to code for FREE!
0

Can we change lists to sets?. What is the main difference between them?

If we were able to change lists to sets, which changes would be occur on lists?

12th Aug 2018, 8:25 AM
Yusif Ibrahimov
Yusif Ibrahimov - avatar
2 odpowiedzi
+ 2
This small code should answer your question. https://code.sololearn.com/ccg2NgzjYa68/?ref=app As you can see, you can change a list into a set using set(list) A set contains every item only once. Maybe most important: sets don't support indexing.
12th Aug 2018, 8:40 AM
davy hermans
davy hermans - avatar
0
Just so you know, you can also do {*list} to convert a list to a set.
12th Aug 2018, 8:17 PM
Just A Rather Ridiculously Long Username