You have to learn to read the tea leaves in the Traceback Error or Syntax Error. The error is usually in the line number specified in the Error message. Sometimes the error is in the line before the line number specified, when something is missing.
Try:
When you get to the syntax error at the bottom of the file, it gets a little tricky, because you first have to fix the error on the top line:
Lewis
Output: File "temp.py", line 52
filename = self.log_path / 'comp{}'.format(url[p 1:])
^
SyntaxError: invalid syntax
From looking at your code and similar lines, you probably want to move the pointer to after the '=' sign similar to other constructions in your code:Try:
filename = self.log_path / 'comp{}'.format(url[p + 1:])The next error is:
Output: File "temp.py", line 54
except KeyError
^
SyntaxError: invalid syntax
Try to figure this one out yourself. Look around at similar constructions to see what is different.When you get to the syntax error at the bottom of the file, it gets a little tricky, because you first have to fix the error on the top line:
f.write('{}\n'.format(td.text) if__name__ == '__main__': GetCompletions('api.txt')which looks like it occurs on the next line. The next line also has an error, which makes it a little tricky for a beginner. Clue to the last error: there is a missing 'space'.
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00