Comparing numbers give the wrong result in Python
<p>sorry if this is a terrible question, but I am really new to programming. I am attempting a short little test program.</p>

<p>If I enter any value less than 24, it does print the "You will be old..." statement. If I enter any value greater than 24 (ONLY up to 99), it prints the "you are old" statement.</p>

<p>The problem is if you enter a value of 100 or greater, it prints the "You will be old before you know it." statement.</p>

<pre><code>print ('What is your name?')
myName = input ()
print ('Hello, ' + myName)
print ('How old are you?, ' + myName)
myAge = input ()
if myAge &gt; ('24'):
     print('You are old, ' + myName)
else:
     print('You will be old before you know it.')
</code></pre>

<p>You're testing a string value <code>myAge</code> against another string value <code>'24'</code>, as opposed to integer values.</p>

<pre><code>if myAge &gt; ('24'):
     print('You are old, ' + myName)
</code></pre>

<p>Should be</p>

<pre><code>if int(myAge) &gt; 24:
    print('You are old, {}'.format(myName))
</code></pre>

<p>In Python, you can greater-than / less-than against strings, but it doesn't work how you might think. So if you want to test the value of the integer representation of the string, use <code>int(the_string)</code></p>

<pre><code>&gt;&gt;&gt; "2" &gt; "1"
True
&gt;&gt;&gt; "02" &gt; "1"
False
&gt;&gt;&gt; int("02") &gt; int("1")
True
</code></pre>

<p>You may have also noticed that I changed <code>print('You are old, ' + myName)</code> to <code>print('You are old, {}'.format(myName))</code> -- You should become accustomed to this style of string formatting, as opposed to doing string concatenation with <code>+</code> -- You can read more about it in <a href="https://docs.python.org/3.5/library/string.html#custom-string-formatting">the docs.</a> But it really doesn't have anything to do with your core problem.</p>

python if-statement