Astronomers were able to find a new planet in a far away solar system. They are
ID: 3778917 • Letter: A
Question
Astronomers were able to find a new planet in a far away solar system. They are calling this planet Nova, for the presence of abundant dements from a supernova. The people of planet Nova speak in a strange language. Thankfully, a scientist was able to decode their language to English. He found that they also use the same letters as English, but they swap each pair of consecutive alphabets in English. For example, they swap A with B and Y with Z. Create a function that reads a word in Nova and translates it into English.Explanation / Answer
def nova(st):
st = list(st)
for i in range(0,len(st)):
if st[i] == 'z':
st[i] = 'a'
elif st[i] == 'Z':
st[i] = 'A'
else:
st[i] = chr(ord(st[i])+1)
return ''.join(str(i) for i in st)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.