I am working on Scratch right now and I am stuck on the code. I’m trying to make a password generator. But I just don’t know how to get the first letter of each word in a sentence
-
1You may find this discussion helpful: https://scratch.mit.edu/discuss/topic/371626/ – Ruud Helderman Oct 18 '21 at 08:57
-
I recommend sharing your code so far so others can build upon it in a way that will be most relevant to you and to future visitors. It's best to ask a concrete question about existing code, not how to implement something. – ggorlen Oct 27 '21 at 19:02
2 Answers
Hopefully this will help you.
(Click here if you would like to see it working.)
Here is how it works:
The repeat runs through the string character by character, and if it hasn't already it stores the first letter of the word in the variable (letter).
If the current letter in the string is a space, it adds the {letter} variable to the list [outputs].
When it is done looping through the string, if the (letter) variable isn't empty it adds it to the [outputs].
You can change the (input) variable to a sentence or string of words, and when ran this will get every first letter of each word.

- 7,102
- 69
- 48
- 77

- 33
- 7
-
3Please note: leading spaces and double spaces in the input will show up as empty elements in the output list. – Ruud Helderman Oct 18 '21 at 08:44
@TheFuturisticIdiot's answer is right but it does not work for leading or double space.
This one does not check the space it, it checks the letters so it will work for leading and double space as well. You can check it out in this project

- 3,425
- 30
- 38
- 48

- 1,096
- 8
- 23