Print last 20 bash history using python and save in pdf file : <p>This code print all the bash history but i have to print last 20 bash history.How can i do that?</p>

<pre><code>import fpdf

pdf = fpdf.FPDF(format='letter')
pdf.add_page()
pdf.set_font("Arial", size=14)

for history in open('.bash_history'):
    pdf.write(8,history)

pdf.output("bash.pdf")
</code></pre>
