I am stuck on how to make Z turn into A on the cs circles problem Next Letter
x =input()
x=x.upper()
x=chr(ord(x) + 1)
print(x)
how do i get z to turn into A?
With reference to English alphabet, the first alphabet and the last one are clubbed together. Similarly, the second and second from the last are placed together. Following this pattern, the next set of alphabets would be DW.
Notes. Five of the letters in the English Alphabet are vowels: A, E, I, O, U. The remaining 21 letters are consonants: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, X, Z, and usually W and Y.
According to this explanation, OTTFFSS riddle answer and answer to What are the next three letters in this combination question is ENT as they represent numbers Eight, Nine and Ten.
Using chr
and ord
:
def next_alpha(s):
return chr((ord(s.upper())+1 - 65) % 26 + 65)
for s in 'abcdefghijklmnopqrstuvwxyz':
print('%s --> %s' % (s, next_alpha(s)))
a --> B
b --> C
...
y --> Z
z --> A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With