Discuss Scratch

Wannabe_Coderrrr
New Scratcher
5 posts

help with creating a simple script (sorry...noobie here)

hello everyone, i hope you are all well. i need help creating a script the main criteria is, whenkey_pressed script that will take a word from the user and display a new word that is the same as the original except that all letters in the second half of the alphabet (n to z inclusive) have been removed.

For example: ‘rhinocerous’ becomes ‘hice’

(again thank you for the help and forgive me for taking up your valuable time )
CoolCrafter1231
Scratcher
100+ posts

help with creating a simple script (sorry...noobie here)

Here a script i made that does just that.
https://scratch.mit.edu/projects/626094071/

Back to help on the forums

Profiles
postpercent | Scratch | ocular
MookyE
Scratcher
100+ posts

help with creating a simple script (sorry...noobie here)

Make a list with all the letters u want to stay

set [Var v] to [0]
repeat (length of (Text))
change [Var v] by (1)
if <[List v] contains (letter (Var) of (Text))?> then
set [Output v] to (join (Output) (letter (Var) of )Text)
end
end

Last edited by MookyE (Jan. 10, 2022 14:19:20)


Hi!
deck26
Scratcher
1000+ posts

help with creating a simple script (sorry...noobie here)

MookyE wrote:

Make a list with all the letters u want to stay


This is a school/college assignment which appears regularly here. On that basis it is better to give hints than complete solutions.
Wannabe_Coderrrr
New Scratcher
5 posts

help with creating a simple script (sorry...noobie here)

CoolCrafter1231 wrote:

Here a script i made that does just that.
https://scratch.mit.edu/projects/626094071/
Thank you!!! I am genuinely Greatful for your help. You helped me a lot ☺️
Wannabe_Coderrrr
New Scratcher
5 posts

help with creating a simple script (sorry...noobie here)

CoolCrafter1231 wrote:

Here a script i made that does just that.
https://scratch.mit.edu/projects/626094071/
I still need help, I have copied the code and it is still not working.

Wannabe_Coderrrr
New Scratcher
5 posts

help with creating a simple script (sorry...noobie here)

MookyE wrote:

Make a list with all the letters u want to stay

set [Var v] to [0]
repeat (length of (Text))
change [Var v] by (1)
if <[List v] contains (letter (Var) of (Text))?> then
set [Output v] to (join (Output) (letter (Var) of )Text)
end
end

any more help if that's ok? when does this get added in. yes you can probably tell how stupid I am
deck26
Scratcher
1000+ posts

help with creating a simple script (sorry...noobie here)

You need to consider this in general terms of achieving your aim.

if you want a list of valid (or invalid) charters that can be set up once and not need doing very time. An alternative is to use a text variable like ‘abcdefghij…’ and check if the variable contains the current letter instead checking whether a list does.

But then essentially all you're doing is

get input
set newtext to blank
set current letter number to 1
repeat until current letter number > length of input
deal with current letter (add/don't add current letter to end of newtext)
change current letter number by 1
end
give result of newtext
Wannabe_Coderrrr
New Scratcher
5 posts

help with creating a simple script (sorry...noobie here)

MookyE wrote:

Make a list with all the letters u want to stay

set [Var v] to [0]
repeat (length of (Text))
change [Var v] by (1)
if <[List v] contains (letter (Var) of (Text))?> then
set [Output v] to (join (Output) (letter (Var) of )Text)
end
end


what would be your written algorithm for this?

Powered by DjangoBB