Indentation in Python is extremely important - it controls the execution flow.
Start by "pulling" the initial stuff over to the left:
import random
guessesTaken = 0
Becomes:
import random
guessesTaken = 0
And so on.
Then check that you haven;t mixed tabs and spaces in your other indents: Python treats them both as a single character whitespace, but the visually appear to be the same:
a = 1
b = 2
The first line has four spaces, the second has one tab character. Python considers them to be different indentation!
Check your editor converts tabs to spaces!