first approach, brutal and just for fun learning Python's syntax
added simpler and more clever approach using regexes