Count repetitions of characters in a string

We want a block that counts the repeated letters in a text box and returns the number of repetitions of each letter

You do not need an extension for this, use lists and list functions to do this. This work has already been demonstrated on the community somewhere...

1 Like

Where

most of the responses were incomplete, because the questions were about homework assignments, which this probably is as well ? here is one of my answers:

Use the text manipulation blocks to get the length of the sentece.
Use the split by block to convert all the characters to a list then compare each character with an alphabet list and do some counting.

2 Likes

Do you want to count for a specific repeated char from a string?

You could loop through the character (text segment in a loop by index number, or for each item in split at empty string), and add 1 to the count (initially 0) of each letter in a dictionary. (key = letter, value = count for that letter.)

Yes how

Are you a student? Is this a homework task?
Taifun

Yes

Yes .

I want images

I dropped the Project on my way to my PC, so the blocks fell apart.
Sorry!


letter_count.aia (2.1 KB)

4 Likes

Minus the blocks

Here's a simple way to count a specific repeated character from a string:

  1. Get the length of the original text.
  2. Replace text by the specific character with empty string.
  3. Get the new length of replaced text.
  4. Subtract the new length from the original length.
  5. Done! Now build those blocks.

I want images

It looks like you do not understand how homework works... it is you who does the work... not others... you got several good hints to do what you need to do... now it's your turn

Taifun

3 Likes

searched the forum and did not find a block that counts the number of letters and how many times they are repeated. I did not find a block, so what is the solution?

You got several good tips in this thread
Show us what you tried

Taifun

This extension will help you do it