Changing timedelta to an integer
<p>OK, so I have to build a program which works out if someone is older than 18, and thus if they can vote.</p>

<p>However, I'm struggling with how to get the program to calculate whether the date of birth entered is more than 18 years ago. I've tried various things, including taking away their date of birth from today's date. </p>

<p>I think it would be easier being able to change the difference between their date of birth date which is currently in datetime.timedelta form, to an integer which can then be compared to 18 in an if statement.</p>

<p>I don't want anything too complicated please.</p>

<p>Here's my current code:</p>

<pre><code>from datetime import datetime
while True:
    inp = input("Enter date in format yyyy/mm/dd")
    try:
        then = datetime.strptime(inp, "%Y/%m/%d")
        break
    except ValueError:
        print("Invalid input")
diff = then - datetime.now()
diff = -diff
years = diff/365.25
years = int(years)
if years &gt;= 18:
    print("You can vote")
else:
    print("You can't vote")
</code></pre>

<p>The current problem is <code>years = int(years)</code> which was a lame way of trying to change it.</p>

<p>How can I fix this?</p>