首页 > 解决方案 > SyntaxError:python 中的语法无效(无法运行代码)

问题描述

L = ["hello", "good day", "hi", "see you", "ciao", "au revoir"]
L.insert(0, L.pop())
print (L)
list(map(len, L[2::2]) 
print (L)

  File "<ipython-input-90-36e680b90dd3>", line 5
    print (L)
        ^
SyntaxError: invalid syntax

在运行代码时出现此错误

标签: python

解决方案


您缺少).list(map(len, L[2::2])

它应该是list(map(len, L[2::2]))


推荐阅读