We run the "Word mix" code , The output will be lie this
The nth word in the output should contain nth letter of each word in the given sentence. The letters of the output word should be in same order as the words in the given sentence. If a word in the given sentence doesn't have n-letters, you can skip it while considering the letters of the n-th word.
Ex: Input :: Welcome to your first problem
Output :: Wtyfp eooir luro crsb otl me em
s = input("Enter string: ")# 'Welcome to your first problem'
w1 = s.split(' ')
w2 = [''] * len(max(w1, key=len))
for i in range(len(max(w1, key=len))):
for k in range(len(w1)):
if i < len(w1[k]):
w2[i] = w2[i] + w1[k][i]
print(' '.join(w2))
Comments
Leave a comment