There are several issues with your code.
First of all, lists are indeed 0-indexed, so you need to substract one (because you start counting from 0, the highest index in the list is the length minus one)
So, this does print the last line:
with open("./hello.txt") as f:
length = len(f.readlines())
with open("./hello.txt") as g:
last_line = g.readlines()[length-1]
print(last_line)
However, in python, there is an easier way to get the last element of a list. You can use negative indexes to wrap around, so, this works as well:
with open("./hello.txt") as g:
last_line = g.readlines()[-1]
print(last_line)
However, if you plan to do more than just read the last line, I would suggest simply storing the list of strings into a variable.
with open("./hello.txt") as g:
file = g.readlines()
# Using your original method
last_line1 = file[len(file)-1]
# Using the negative indexes
last_line2 = file[-1]
print(last_line1, last_line2)
If your file is big and you cannot just read the entire file, and you need to read only the last line, it can also be beneficial to check out this question:
How to read the last line of a file in Python?
I hope that helps!