What you show isn't python, I think. I think you should start with a hello world python program, in a text file, then extend it one step at a time until you get where you need to go. Working in the python line editing environment is fine for a quick little test, but you have to re-enter everything every time you need a change, so the text script file is much better for programming.
Hint: Python string with \1 or \2 in it should be spelled r'\2' for instance (note the leading r) ... or you need to escape the backslash: '\\2'
griswolf
Veteran Poster
1,176 posts since Apr 2010
Reputation Points: 344
Solved Threads: 262
Skill Endorsements: 1