Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Remove letters from a word
- yazzi619
-
6 posts
Remove letters from a word
Hi I'm wondering if anyone knows how to create a code with variables, that can remove every letter of a word except for the middle letter(s). The program will previously ask the person for the word of their choice. I need this for an assignment please it's urgent!!
- TheWeeklyReader
-
100+ posts
Remove letters from a word
Can you post the project? Do you mean like if i enter the word “you” it shows up with just “yu”? or do you mean “you” into “o”?
- yazzi619
-
6 posts
Remove letters from a word
Can you post the project? Do you mean like if i enter the word “you” it shows up with just “yu”? or do you mean “you” into “o”?
I want to make it so that if the word has an even amount of letters it will take the middle two characters, and if it has an odd amount of letters it takes only the one middle character if that makes sense. Like with the word “you” it would just take the “o”, and with the a word like “away” it would take “wa”. Love the quote btw lol
Last edited by yazzi619 (Nov. 17, 2022 01:42:10)
- TheWeeklyReader
-
100+ posts
Remove letters from a word
i hope this is what you wanted, it doesnt work that well, also very inefficient, but it works for lengths 3 and 5
note: im just dumb like that and forgot to post the link:
random project that is very inefficient
note: im just dumb like that and forgot to post the link:
random project that is very inefficient
Last edited by TheWeeklyReader (Nov. 17, 2022 01:59:46)
- Jlerpy
-
1000+ posts
Remove letters from a word
i hope this is what you wanted, it doesnt work that well, also very inefficient, but it works for lengths 3 and 5
note: im just dumb like that and forgot to post the link:
random project that is very inefficient
You haven't made it shared.
- TheWeeklyReader
-
100+ posts
Remove letters from a word
i shared it, havn't changed it at alli hope this is what you wanted, it doesnt work that well, also very inefficient, but it works for lengths 3 and 5
note: im just dumb like that and forgot to post the link:
random project that is very inefficient
You haven't made it shared.
yours is way better, i made it remove the middle letter and show the rest. You could make it so you can do spaces, and it combines them, so if i entered
why zip, it would turn into “hi”
Last edited by TheWeeklyReader (Nov. 17, 2022 16:31:26)
- MistaLOD
-
100+ posts
Remove letters from a word
define Remove Letter (#) from (Variable)
set [Output v] to ()
if <(#)<((length of (Variable))+(1))> then //check if # can be removed
set [i v] to (1)
repeat until <(i) = (#)>
set [Output v] to (join (Output) (letter (i) of (Variable)))
change [i v] by (1)
end
change [i v] by (1)
repeat until <(i) = ((length of (Variable)) + (1))>
set [Output v] to (join (Output) (letter (i) of (Variable)))
change [i v] by (1)
end
else
set [Output v] to (Variable)
end
set [name v] to [Michael] //name = Michael
Remove Letter (4) from (name)
set [name v] to (Output) //name = Micael
- Oumuamua
-
1000+ posts
Remove letters from a word
...
set [name v] to [Michael] //name = Michael
Remove Letter (4) from (name)
set [name v] to (Output) //name = Micael
The OP wants to remove all letters but the middle one.
- scratching_claws
-
71 posts
Remove letters from a word
This is simpler: Hi I'm wondering if anyone knows how to create a code with variables, that can remove every letter of a word except for the middle letter(s). The program will previously ask the person for the word of their choice. I need this for an assignment please it's urgent!!
define get middle letters (word)
if <((length of (word)) / (2)) contains (.5)> then
set [return v] to (letter(length of([ceiling v] of ((word)/(2)))) of (word)
else
set [return v] to (join(letter(length of((word)/(2))) of (word))(letter(length of(((word)/(2))+(1))) of (word)
end
when green flag clicked
ask [Please enter a string] and wait
get middle letters(answer)
say(return)
Last edited by scratching_claws (Nov. 17, 2022 18:11:51)
- MistaLOD
-
100+ posts
Remove letters from a word
If you just want the 1 (or 2) middle letter(s), you can do this instead:
when green flag clicked
ask [Enter String:] and wait
Middle Letters (answer)
say (output)
define Middle Letters (String)
if <((length of (String)) mod (2)) = (1)> then
set [output v] to (letter (((length of (String)) + (1)) / (2)) of (String))
else
set [output v] to (join (letter ((length of (String)) + (1)) of (String)) (letter (((length of (String)) + (2)) / (2)) of (String))
end
- Discussion Forums
- » Help with Scripts
-
» Remove letters from a word