Welcome to stack overflow. A few things I will point out:
In this segment:
for index_3 in range(0,8):
xAxis = []
xAxis.append(random.randint(0,8))
yAxis = []
yAxis.append(random.randint(0,8))
You loop and set xAxis and yAxis to empty list every time before you add a random int to the lists. Because of that, at the end of the loop, yAxis and xAxis only have one element.
To fix it, move xAxis = [] and yAxis = [] before the loop.
Additionally, randint(0, 8) includes both start and end in the return. You want randint(0, 7) so you don't get index out of range.
Next:
nums = range(0,8)
for num in nums:
[ocean[yAxis[num]]] = 2
Here, yAxis only has one element, but even after you fix it, it should throw an error. What you would be trying to do is unpacking a list, but 2 is not a list.
[ocean[yAxis[num]]] = 2 would be the same as writing ocean[yAxis[num]], = 2. Now that , looks out of place. So what you are probably looking for is ocean[yAxis[num]] = 2.
But, being as ocean is [[0,0,0,0,..],[0,0,0,0,...],...], you probably don't want to set one of it's elements to 2. You want to set one of the nested lists's elements to 2.
Maybe something like this:
nums = range(0,8)
for num in nums:
ocean[xAxis[num]][yAxis[num]] = 2
so ocean will look like:
[
[0,0,2,0,0,2,0,0],
[0,0,2,0,0,0,0,0],
...
]