Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am Continuously getting SyntaxError when I try to print a str and len() together. Please advise

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]))

1 Answer

0 votes
by (36.8k points)

You have missed one closing parenthesis

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])))

 If you are a beginner and want to know more about Data Science the do check out the Data Science course

Also, check this out for similar question

Related questions

+1 vote
3 answers
asked Oct 3, 2019 in Python by Sammy (47.6k points)
0 votes
0 answers
0 votes
1 answer
asked Aug 24, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...