main.py#

This is Exercise 1 of the Micro Python Tutorial.

The file main.py is special in MicroPython, only in the sense that when you power-on the device and/or press the reset button, the main.py file is executed.


# this is a comment

print('hello world.') print("hello again.")

There is a structure in Python called a try-except-finally block, which is ideal for a main.py file:


# this is a comment

try: print('hello world.') except Exception: print('an error occurred: {}'.format(e)) finally: print('complete.')

Remember to indent the insides of your blocks by 4 characters.