extra empty element when removing an element from a tuple

前端 未结 2 814
一个人的身影
一个人的身影 2021-01-15 03:12

I have a question about the following python outcome. Suppose I have a tuple :

a = ( (1,1), (2,2), (3,3) )

I want to remove (2,2)

2条回答
  •  温柔的废话
    2021-01-15 03:57

    It indicates a one-element tuple, just to prevent confusion.

    (1,) is a tuple, while (1) is just the number 1 with unnecessary parentheses.

提交回复
热议问题