+ 1
In how many ways can we send list variable values to tuple variable in python?
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.
+ 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
+ 1
Yeah I was thinking about that also.