I'd like to convert the list into a collection

Asked 1 years ago, Updated 1 years ago, 78 views

list2007 = []

for i in range(len(res2007)):

    a = res2007[i][0]
    list2007.append(a)

set2007 = set([list2007])

TypeError Traceback (most recent call last)

in ()

----> 1 set2007 = set([list2007])

TypeError: 'tuple' object is not callable

For your information, res2007 is also a list type.

list set convert python3

2022-09-22 18:39

1 Answers

You can do it as below.

L = list(range(10))
print(set(L))

{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}


2022-09-22 18:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.