📌  相关文章
📜  如何在python代码示例中从逗号分隔的字符串中获取列表

📅  最后修改于: 2022-03-11 14:46:06.139000             🧑  作者: Mango

代码示例3
##Write a Python program to input a string that is a list of words separated by commas. 
##Construct  a dictionary that contains all these words as keys and their frequencies as values.
##Then display  the words with their quantities.  

lst = []
d = dict()
user = input ("enter a string ::-- ")
lst = user.split(',')
print("LIST ELEMENR ARE :: ",lst)
l = len(lst)
for i in range(l) :
    c = 0
    for j in range(l) :
        if lst[i] == lst[j ]:
            c += 1
    d[lst[i]] = c
print("dictionary is  :: ",d)