I want to print the last character of string in python reading from the file.
I am calling as str[-1] but it is not working as expected.
str[-1]
The last character of every line is a newline character. You can strip it:
print(line.strip()[-1]) # or print(line.rstrip()[-1])