+ 1

In how many ways can we send list variable values to tuple variable in python?

27th Dec 2019, 9:22 AM
muthu kumar
muthu kumar - avatar
3 Antworten
+ 4
If you define a function with a star def f(*x): ... you can pass as many arguments as you want. They will be accessable in a tuple called x. You can pass a list to such a function: f(*your_list) It will be unpacked and packed right away to a tuple.
27th Dec 2019, 9:59 AM
HonFu
HonFu - avatar
+ 3
Here's one I know my_tuple = tuple(my_list) Why tag 'sets'? are you also asking how it's done from `list` to `set`? (Edit) my_set = set(my_list) That's about it for `list` to `set` ... I updated my answer muthu kumar
27th Dec 2019, 9:41 AM
Ipang
+ 1
Yeah I was thinking about that also.
27th Dec 2019, 9:45 AM
muthu kumar
muthu kumar - avatar