Horje
for loop to create a set of counters in python Code Example
for loop to create a set of counters in python
book_title =  ['great', 'expectations','the', 'adventures', 'of', 'sherlock','holmes','the','great','gatsby','hamlet','adventures','of','huckleberry','fin']
word_counter = {}

for word in book_title:
    if word not in word_counter:
        word_counter[word] = 1
    else:
        word_counter[word] += 1

# output
# {'great': 2, 'expectations': 1, 'the': 2, 'adventures': 2, 'of': 2, 'sherlock': 1, 'holmes': 1, 'gatsby': 1, 'hamlet': 1, 'huckleberry': 1, 'fin': 1}




Python

Related
json url to dataframe python Code Example json url to dataframe python Code Example
django list view Code Example django list view Code Example
how to play audio Code Example how to play audio Code Example
var person Code Example var person Code Example
how to use event of Button in python Code Example how to use event of Button in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10