I have a list, somewhat similar to the one below.
lines = ['This is line 1',
'This is another line',
'This is the third line. Line 03.']
When I run the return statement to process for the len of the line,
for line in lines:
return(len(line))
generates the following error:
File "", line 2
return(len(line))
^
SyntaxError: 'return' outside function
I can however print the lengths of the lines,
for line in lines:
print(len(line))
Result:
14
20
32
How exactly is the return statement outside function in this instance?
