Syntax error at line 1

You may get a syntax error at line 1 error after pasting example MicroPython code and pressing Ctrl+D.

Solution

This commonly happens when you accidentally type a character at the beginning of line 1 before pasting the code.