I would like to add numbers in a dictionary, cumulative so it will add the keys of the dictionary.
x = ' '
dict = {}
list = []
while x != '':
x = raw_input('Enter line:')
p = x.split(' ')
if x != '':
list.append(p)
result = sum(list, [])
result = result
num = []
for a in result:
for n in dict:
p = a.count(a)
l = a
if n == l:
l += l
dict[a] = p
print dict
raw_input('')
I would like “dict” to consist of the words from the input and the amount of times that they were entered.
Thanks
use
Counter:output:
and without using
Counter(which is not recommended) you can usesets:output: