Answer to Question #227665 in Python for ravi

Question #227665

Convert list [""python"", ""is"", ""a"", ""programming"", ""language""] into string"

"python is a programming language""


second Problem


a= "python is a programming language"

expected output:- {"python"=6, "is"=2,a""=1,"programing"=11, "language"=8}


1
Expert's answer
2021-08-19T14:31:42-0400
list_words = ["Python","is","a","programming","language"]
#combine list items into a sentence with a space delimiter character
sentence = ' '.join(list_words)
print('"' + sentence + '"')
a = "python is a programming language"
#spliting a sentence into words, by default by space
words = a.split()
print("{", end = '')
for word in words:
    if word == words[-1]:
        print('"' + word + '"' + '=' + str(len(word)), end = '}\n')
    else:
        print('"' + word + '"' + '=' + str(len(word)), 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