title: CS circles Coding Exercise: 26 Letters
body: <p>This coding exercise is giving me a lot of trouble and I need help.</p>
  
  <p>Here is the problem.</p>
  
  <blockquote>
    <p>Write a program which does the reverse of the example above: it should
    take a character as input and output the corresponding number (between
    1 and 26). Your program should only accept capital letters. As
    error-checking, print invalid if the input is not a capital letter.</p>
  </blockquote>
  
  <p>Here is what I have so far.</p>
  
  <pre><code>inp = input()
  
  if (len(inp) &gt; 1 or inp != inp.upper()):
      print("invalid input")
  
  else:
      print(ord(inp)-ord("A")+1)
  </code></pre>