yield outside of functions
- It has no meaning there
print("one")
yield "ok";
print("two")
Output:
File "examples/generators/yield_outside_any_function.py", line 2
yield "ok";
^
SyntaxError: 'yield' outside function
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
print("one")
yield "ok";
print("two")
Output:
File "examples/generators/yield_outside_any_function.py", line 2
yield "ok";
^
SyntaxError: 'yield' outside function