1

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

Linh Tran
  • 29
  • 1
  • 1
    You 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 Answers2

2

Hopefully this will help you.

Scratch code to get the first letter of each word in a string.

(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.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
1

@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

Image of code

Neptotech -vishnu
  • 1,096
  • 8
  • 23