Learning problems in Python June

CSDN Q & A 2022-05-14 15:46:57 阅读数:823

learningproblemspythonjune

do not know why , When I started learning with the instructional video , It runs normally , It's not normal to open it today .

img


I write :
lol_list = [
[' On a single ',' Cheng Yaojin ',20]
[' Master ',' The sable cicada ',21]
[' striker ',' Meng ya ',22]
[' A wild ',' Li Bai ',23]
[' auxiliary ',' Cai Wenji ',24]
]

establish DataFrame

df = DataFrame(data=lol_list)

Prompt error :
TypeError Traceback (most recent call last)
in
2 lol_list = [
3 [' On a single ',' Cheng Yaojin ',20]
> 4 [' Master ',' The sable cicada ',21]
5 [' striker ',' Meng ya ',22]
6 [' A wild ',' Li Bai ',23]

TypeError: list indices must be integers or slices, not tuple

I look confused , I hope you can help solve it .




Take the answer :

The comma between the arrays in the array is missing

img


There should be a comma in the circle


版权声明:本文为[CSDN Q & A]所创,转载请带上原文链接,感谢。 https://pythonmana.com/2022/134/202205072323425608.html