setdefault python 1

setdefault python

manga_names = {}
with open('manga_list.txt', 'r') as file:
    manga = file.readline()
    file.readline()
    manga_names.setdefault(manga, 0)
    manga_names[manga] += 1

Here is what the above code is Doing:
1. We open the file in read mode.
2. We read the first line of the file.
3. We read the second line of the file.
4. We create a dictionary with the manga name as the key and the value as 0.
5. We add 1 to the value of the manga name key.

Similar Posts