Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 432 characters in body; added 98 characters in body
Source Link
YOU
  • 124.5k
  • 34
  • 192
  • 222

Normally, Just ord and add 2 and chr back, (Y, Z will give you unexpected result ("[","")

>>> chr(ord("A")+2) 'C' 

If you want to change Y, Z to A, B, you could do like this.

>>> chr((ord("A")-0x41+2)%26+0x41) 'C' >>> chr((ord("Y")-0x41+2)%26+0x41) 'A' >>> chr((ord("Z")-0x41+2)%26+0x41) 'B' 

Here is A to Z

>>> [chr((i-0x41+2)%26+0x41) for i in range(0x41,0x41+26)] ['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B'] 
>>> chr(ord("A")+2) 'C' 

Normally, Just ord and add 2 and chr back, (Y, Z will give you unexpected result ("[","")

>>> chr(ord("A")+2) 'C' 

If you want to change Y, Z to A, B, you could do like this.

>>> chr((ord("A")-0x41+2)%26+0x41) 'C' >>> chr((ord("Y")-0x41+2)%26+0x41) 'A' >>> chr((ord("Z")-0x41+2)%26+0x41) 'B' 

Here is A to Z

>>> [chr((i-0x41+2)%26+0x41) for i in range(0x41,0x41+26)] ['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B'] 
Source Link
YOU
  • 124.5k
  • 34
  • 192
  • 222

>>> chr(ord("A")+2) 'C'