title: Python Simple Encryption program: How to loop Z back to A
body: <p>I'm trying to make an encryption function that encrypts plaintext messages but the problem is that if i input a key too large that goes past 'Z' then it goes onto greater unicode values.</p>
  
  <p>My code:</p>
  
  <pre><code>def encrypt(var1,var2): 
      var3 = ""
      for i in range(0, len(var1)):
          if ord(var1[i])&gt;64 and ord(var1[i])&lt;90:
              var3=var3+chr((ord(var1[i])+var2))
          elif ord(var1[i])+var2&gt;90:
              ???
          else:
              continue
      return(var3)
  </code></pre>
  
  <p>How do I get it to loop 'Z' back to 'A'. I think I have to make an if statement like this but I'm not sure what to put into it.</p>
  
  <pre><code>elif ord(var1[i])+var2&gt;90:
      ???
  </code></pre>