Start by learning Python: it is an unusual language in that indentation is significant - it determines what code is part of what.
So when you create a function, all the code in the body of the function must be indented to the same level (or greater) and that level of indentation cannot be zero.
So this makes a two line function:
def foo():
line1
line2
line3
In your code, none of it is indented, so nobody can tell what is supposed to be part of the function and what isn't.
So fix that, then try again to see how well it works.