How to shorten year into two-number integer in Python?
<p>I have a basic block of code, and a portion of it asks the user their year of birth. In order to complete the program, I need their year (e.g. 1997) to be shortened into a two-number integer (e.g. 97). At the moment, the only way I can work out is to subtract 2000, but obviously that barely works.</p>

<pre><code>year=input("And finally, what's the year of your birthday? ")
shortyear=int(year)-2000
</code></pre>

<p>I have researched online into slicing strings and integers but none of them seem to work for me. I'm still extremely basic at Python but I'm guessing that there should be a way to select only the last two characters in an integer?:</p>

<pre><code>intyear=int(year)
shortyear=year[-2:]
</code></pre>

<p>That doesn't seem to work for me, though. Hopefully, someone will have an answer that works!</p>

<p>Thank you very much! í ½í¸í ½í±í ¼í¿½</p>

<p>you can use <code>year%100</code> to only get the digits within a century:</p>

<pre><code>&gt;&gt;&gt; 2000%100
0
&gt;&gt;&gt; 2013%100
13
&gt;&gt;&gt; 1985%100
85
&gt;&gt;&gt; 1997%100
97
</code></pre>

python