Can you rewrite this program to work in micropython?