SyntaxError:解析时出现意外的EOF(Python)

2024-09-27 18:04:20 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图同时打印str和len()时,会不断出现SyntaxError。请告知

companies = [['Google', 'Facebook', 'Apple'],
            ['Warner Bros. Pictures', '20th Century Fox', 'Universal Pictures'],
            ['Whole foods', 'Starbucks', 'Walmart']]


for x in range(len(companies)):
    for y in range(len(companies[x])):
        print("This company name has length of:" + " " + str(len(companies[x][y]))

Tags: inappleforfacebooklengooglerangecompanies
1条回答
网友
1楼 · 发布于 2024-09-27 18:04:20

你刚刚错过了一个右括号

companies = [['Google', 'Facebook', 'Apple'],
            ['Warner Bros. Pictures', '20th Century Fox', 'Universal Pictures'],
            ['Whole foods', 'Starbucks', 'Walmart']]


for x in range(len(companies)):
    for y in range(len(companies[x])):
        print("This company name has length of:" + " " + str(len(companies[x][y])))

相关问题 更多 >

    热门问题