The function accepts two characters ‘ch1’ and ‘ch2’ as the argument. ‘ch1’ and ‘ch2’ are alphabetical letters. Implement the function to find and return the next letter so that distance between ch1 and ch2. While counting distance if you exceed the letter ‘z’ then count the remaining distance starting from the letter ‘a’.
Distance between two letters in the number of letters between them.
All input and output characters are lower case alphabets.
Input 1: c
Input 2: g
The distance between the letter ‘c’ and ‘g’ is 3 (d,e,f). The next letter with distance 3 from letter ‘g’ is ‘k’. Thus the output is k.
Input 1: r
Input 2: l
Solution in Python 3:
# https://codewindow.in s1=input() s2=input() asc_s1 = ord(s1) asc_s2 = ord(s2) #print(asc_s1) #print(asc_s2) count=asc_s2-asc_s1 print(chr(asc_s2+count)) # Join Telegram @codewindow
r l f