Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
Added new script
Browse files Browse the repository at this point in the history
  • Loading branch information
FloChiff committed Jun 5, 2024
1 parent 8c58d33 commit 3140cbf
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/local/bin/python
# -*- coding: utf-8 -*-

def count_characters(text):
# Create an empty dictionary to store character occurrences
char_count = {}

# Iterate through each character in the text
for char in text:
# Check if the character is already in the dictionary
if char in char_count:
# If it is, increment the count
char_count[char] += 1
else:
# If it's not, add it to the dictionary with a count of 1
char_count[char] = 1

# Print the character occurrences
for char, count in char_count.items():
print(f"'{char}' = {count}")

text_to_read = #Content of the text from which characters will be counted
count_characters(text_to_read)

0 comments on commit 3140cbf

Please sign in to comment.