Answer to Question #280388 in Python for solokin

Question #280388

Write a Python program that does the following.



Create a string that is a long series of words separated by spaces. The string is your own creative choice. It can be names, favorite foods, animals, anything. Just make it up yourself.



Turn the string into a list of words using split.



Delete three words from the list, but delete each one using a different kind of Python operation.



Sort the list.



Add new words to the list (three or more) using three different kinds of Python operation.



Turn the list of words back into a single string using join.



Print the string.


1
Expert's answer
2021-12-17T06:57:16-0500
my_words = 'car cat red dog chair parking money pillow picture turtle ' \
        'KFC bottle sheep chicken marten bear read comp phone mouse horse'

# creating a list of words
listing = my_words.split()

# deleting  items from the list
listing.remove('dog')
listing.pop(-1)
del listing[1]

# sorting made list
listing.sort()

# adding elements or words to our list
listing.append('computer')
listing.insert(5,'milano')
listing.extend(['Rio', 'China'])

# list is to string
final_words = ' '.join(listing)
print(final_words)

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

saksham
11.02.22, 18:56

good work

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS