Concatenating Tuple

前端 未结 7 1254
-上瘾入骨i
-上瘾入骨i 2020-12-29 20:40

Suppose I have a list:

a=[1,2,3,4,5]  

Now I want to convert this list into a tuple. I thought coding something like this would do:

7条回答
  •  萌比男神i
    2020-12-29 21:45

    tuple is not mutable in python.

    so after you initial it with tuple(...), it can't be modified.

    a = [1,2,3,4,5]
    tuple(a) 
    

提交回复
热议问题