word = input ('Enter a word: ')
vowels = {'a', 'e', 'i', 'o', 'u'}
results = {}
for c in word:
if c in vowels:
results[c] = results.get(c, 0)
# results[c] = results.get(c, 0) + 1
for k, v in results.items():
print (k, " is present", v, "times")
In the above code, I don't understand. what is the mean by -
results.get(c, 0) + 1
and what is the difference between?
results.get(c, 0) + 1
results.get(c, 0)
at first, I thought that "results.get(c, 0) + 1" gives the output based on an empty dictionary, but when I executed this code "results.get(c, 0)", my understanding of get method got confused.