Issue
x = [1,2,3,4,5,6,7,8,9,0] for element in x: return element
gives IndentationError: expected an indented block
x = [1,2,3,4,5,6,7,8,9,0] for element in x: return element
gives error>>> SyntaxError: 'return' outside function
Solution
You need to define this in a function and call that function for the return value. Something like this -
x = [1,2,3,4,5,6,7,8,9,0]
def find_element():
for element in x:
return element
a = find_element()
print (a)
Code - https://ide.geeksforgeeks.org/MGO9MBWFyz
Answered By - geekanant
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.