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]
Simple, take the string and clear it's leading and trailing spaces. Then return the last character in your case. Otherwise simply return last character.
line=line.strip() return line[-1]