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}
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 = ', ')
Comments
Leave a comment