title: Python try/except with Collatz sequence
body: <p>I'm trying to write a Collatz sequence while adding a try and except statements to detect whether the user types in a noninteger string and I can't seem to figure out how to do so. If read <a href="https://stackoverflow.com/questions/730764/try-except-in-python-how-do-you-properly-ignore-exceptions">Try/Except in Python: How do you properly ignore Exceptions?</a>, but am still at a loss. My code so far:</p>
  
  <pre><code>def collatz(y):
      try:
          if y % 2 == 0:
              print(int(y/2))
              return int(y/2)
  
          else:
              print(int(y*3+1))
              return int(y*3 +1)
  
      except ValueError:  
          print('Error: Invalid Value, the program should take in integers.')
  
  print('Please enter a number and the Collatz sequence will be printed')
  x = int(input())
  
  while x != 1:
      x = collatz(x)
  </code></pre>