Answer to Question #198375 in Python for Latha

Question #198375

We run the "Word mix" code , The output will be like 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


But,run the above code displayed only "Wtyfp" .


1
Expert's answer
2021-05-25T05:42:32-0400
s = input().split()
l = list()
for word in s:
    for i in range(len(word)):
        if (len(l) > i):
            l[i] += word[i]
        else:
            l.append(word[i])
            
for i in l:
    print(i, end=' ')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS