How to pick one number of an Integer
<p>How can I pick one of the digits from an Integer like: 97723
and choose (for example) the number 2 from that number and check if its an odd or an even number?</p>

<p>Also, can I print only the odd numbers from an Integer directly? (Is there any default function for that already?)</p>

<p>Thanks in advance</p>

<p>If you want to "parse" a number the easiest way to do this is to convert it to string. You can convert an int to string like this <code>s = string(500)</code>. Then use string index to get character that you want. For example if you want first character (number) then use this <code>string_name[0]</code>, for second character (number) use <code>string_name[1]</code> . To get length of your string (number) use <code>len(string)</code>. And to check if number is odd or even mod it with 2.</p>

<pre><code># Converting int to string
int_to_sting = str(97723)

# Getting number of characters in your string (in this case number)
n_of_numbers = len(int_to_sting)

# Example usage of string index
print("First number in your number is: ",int_to_sting[0])
print("Second number in your number is: ",int_to_sting[1])

# We need to check for every number, and since the first number is int_to_sting[0] and len(int_to_sting) returns actual length of string we need to reduce it by 1
for i in range(n_of_numbers-1):
        if int_to_sting[i]%2==0:
              print(int_to_sting[i]," is even")
        else:
              print(int_to_sting[i]," is odd")
</code></pre>

python python-3.x