How to create a tuple of an empty tuple in Python?

后端 未结 3 1428
旧巷少年郎
旧巷少年郎 2020-12-15 15:33

How can I create a tuple consisting of just an empty tuple, i.e. (())? I have tried tuple(tuple()), tuple(tuple(tuple())), tuple

3条回答
  •  渐次进展
    2020-12-15 16:00

    I'm not surprised this (()) didn't work, since the outer parentheses get interpreted as that - parentheses. So (()) == (), just like (2) == 2. This should work, however:

    ((),)
    

提交回复
热议问题