title: Check a valid credit card number using python
body: <p>This is a homework assignment that I've been working on to compute if a credit card number is valid. It has many steps and uses 2 other helper functions.</p>
  
  <p>The first helper function makes a list consisting of each digit in n:</p>
  
  <pre><code>def intToList(n):
      strr = [num for num in str(n)]
      theList = list(map(int, strr))
      return theList
  </code></pre>
  
  <p>The second helper function adds the sum of digits in a number. For example:</p>
  
  <pre><code>def addDigits(n):
      sums = 0
      while n:
          if n &gt; 0:        
              sums += n % 10
              n //= 10
          else:
              return
      return sums
  
  &gt;&gt;&gt;(332) #(3+3+2) = 7
  &gt;&gt;&gt; 7
  </code></pre>
  
  <p>So the function I am working on is suppose to validate a 16 digit credit card number. It has specific orders to follow in the order given.</p>
  
  <ol>
  <li>Verifies that it contains only digits. #Done.</li>
  <li>Verifies that it is 16 digits long. #Done.</li>
  <li>if n is a string, it converts it to an integer.</li>
  <li>creates a list using the function intToList(n).</li>
  <li>Multiplies the odd indices of the list made by intToList(n) by 2 and any products that produce two-digit numbers are replaced by the sum of the digits using the function addDigits(n).</li>
  <li>Computes the sum of all the single digits in the list made my intToList(n). If the sum is equal to 0 modulo 10, the original value, n, is a valid credit card number. </li>
  </ol>
  
  <p>As of right now I have this:</p>
  
  <pre><code>def checkCreditCard(n):
      #Suppose to convert n to int.
      n = int(n)
      #Helper function 1 to make a list.
      myList = intToList(n)
      #For loop to apply the math to each odd indices.*
      for ele in myList:
          if ele % 2 == 1:
              ele *= 2
          if ele &gt;= 10:
              single = addDigits(?) #not sure what to put I've tried everything
          if sum(myList) % 10 == 0:
              return True
          return False
  </code></pre>
  
  <p>Here is my issue, I am unsure where to go from here. I am pretty sure the code above is correct so far, but I don't know how to make the products that produce two-digit numbers compute to single digit ones using my function and computes the sum of all the single digits in the list.</p>
  
  <p>Any help would be greatly appreciated. Let me know if I can clear anything up.</p>
  
  <p>added what I've worked on.</p>