Python 列表理解-2元素列表

Python 列表理解-2元素列表,python,list,Python,List,创建2元素列表- ["atom", "nuclei", "neuron"] to display as: 使用列表和结果计算数字以显示如下内容= [["atom",4], ["nuclei",6], ["neuron", 6], ["physics", 7]] 在这里: >>> my_list = ["atom", "nuclei", "neuron"] >>> [[v, len(v)] for v in my_list] [['atom', 4], ['

创建2元素列表-

["atom", "nuclei", "neuron"] to display as:
使用列表和结果计算数字以显示如下内容=

[["atom",4], ["nuclei",6], ["neuron", 6], ["physics", 7]]
在这里:

>>> my_list = ["atom", "nuclei", "neuron"]
>>> [[v, len(v)] for v in my_list]
[['atom', 4], ['nuclei', 6], ['neuron', 6]]