我有这个嵌套列表 X_train
X_train = [['sunny', 'hot', 'high', 'FALSE'],
['sunny', 'hot', 'high', 'TRUE'],
['overcast', 'hot', 'high', 'FALSE'],
['rainy', 'mild', 'high', 'FALSE'],
['rainy', 'cool', 'normal', 'FALSE'],
['rainy', 'cool', 'normal', 'TRUE'],
['overcast', 'cool', 'normal', 'TRUE'],
['sunny', 'mild', 'high', 'FALSE'],
['sunny', 'cool', 'normal', 'FALSE'],
['rainy', 'mild', 'normal', 'FALSE'],
['sunny', 'mild', 'normal', 'TRUE'],
['overcast', 'mild', 'high', 'TRUE'],
['overcast', 'hot', 'normal', 'FALSE'],
['rainy', 'mild', 'high', 'TRUE']]
Run Code Online (Sandbox Code Playgroud)
我想生成一个列表,其中的第 n 行X_train包含X_train. 所以预期的输出应该是:
[{'overcast', 'rainy', 'sunny'},
{'cool', 'hot', 'mild'},
{'high', 'normal'},
{'FALSE', 'TRUE'}]
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
questions=[] …Run Code Online (Sandbox Code Playgroud)