Why does [-1] not return the last character of the line in a file?
<p>I want to print the last character of string in python reading from the file.</p>
<p>I am calling as <code>str[-1]</code> but it is not working as expected.</p>
<p><strong>t.txt contains</strong></p>
<pre class="lang-none prettyprint-override"><code>Do not laugh please!        9
    
Are you kidding me?     4
</code></pre>
<p>My code is</p>
<pre class="lang-py prettyprint-override"><code>with open('t.txt', 'r') as f:
    for line in f:
        print(line)
        print(line[-1])
        # break
</code></pre>
<p>But it is not printing anything.</p>