Word Mix in Python | Assignment Expert

Problem Statement:

We are given a sentence, we need to word mix in Python means we need to mix the words of the sentence such that new words get formed. How? We need to select a letter from each word from the same index. If there is no letter in the word, do nothing and proceed further.

For example, sentence=> “Welcome to CopyAssignment”=> WtC eoo lp cy oA ms es i g n m e n t

Code for Word Mix in Python:

sentence = 'Welcome to CopyAssignment'
words = sentence.split()
max_len_list = max(words, key = len)
max_len = len(max_len_list)
for i in range(max_len): # for looping max word length times
    for j in range(len(words)): # for looping numbers of words time
for i in new_words:
for i in word_list:
    print(i, end="   ")


Word Mix in Python | Assignment Expert


We have accessed the letters of each word of the sentence, but not all words do not have the same numbers of letters that are why we have used the try and except block of Python. It saved us from throwing error even when we are accessing a string index that does not exist. We hope you find your solution to Word Mix in Python.

Also Read:

Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you