데이터의 처음 세 열을 새로운 빈 목록에 추가 할 수있는이 함수가 있습니다. 출력 예는 다음과 같습니다파이썬 목록에 여러 목록 추가
['red', 'blue', 'green', 'yellow', 'purple', 'black']
나는 자신의 목록에이 목록의 모든 두 요소를 둘러싸 싶습니다 즉
[['red', 'blue'], ['green', 'yellow'], ['purple', 'black']]
내가 어떻게 할 수 있습니까? 감사.
def selection_table(table):
atts = [1,2,3]
new_table = []
for row in table:
for i in range(len(new_atts)):
new_table.append(row[atts[i]])
return new_table
대단히 감사합니다. – shutoutzilla37