Hi, how can I loop through a sentence that a user inputs using a for loop and get the number of words the user inputs with the repeated words or characters? Thank you
Provide an example input senctence, and expected output as an example.
for example, if a user enter apple," it will count each character like a-p-p-l-e and the output will be 5-character or sentence The repeat word, like pp, will also show how many times it occurred
Apple is not a sentence.
Please explain and show exactly what it is you are trying to achieve, it is not clear, to me, so far....
i am trying to work on projects that count every character the user inputs, for example, "Jim is going to school."
The output will be: length is 13 and the repeated characters is o and i
I believe the OP wanted to count the individual characters used, three lists are needed. Also these blocks do no handle any punctuation so the full stop is included in the count.
Thank you! This is what I am trying to achieve.
you are so good at this. Thank you
Hi Anke,
what is the call countChars meant to do? because there is a button what I'm i suppose to put in the button block. Another question I have is can the procedure handle multiple user inputs?
After trying the code you posted, my output was totally different from yours. where is the error coming from?
You used a "split at spaces" block. Tim used "empty string" splitting. Tim's blocks are dragged, so drag them to your blocks to eliminate block misrecreation..
Is there a way you can break the code down for me to understand, like by adding a comment? Thank you
In simple terms
- Remove the spaces from the sentence.
- Break the sentence up into a list of ALL the characters.
- We iterate over this list (using indexes because of the likely list duplicates).
a) Add each letter to the first list, if it is not in the first list. This builds your requirement for a list of all the characters in the sentence
b) If the letter is already in the first list, then add it to the second list (if it is not already in the second list). This build your requirement for repeated characters in the sentence. - Display the two lists and the length of each.
Just curious: is there another way to solve this question?
Probably
Thanks for helping out .
what is output like for this?