Discuss Scratch

mecodetwo
Scratcher
100+ posts

784 contains letters

in my project https://scratch.mit.edu/projects/575925419/ I have a
<(784) contains (item (letter check :: variables) of [letters v] :: list) :: operators>
where ‘letters’ is a list of a-z and A-Z, but it is returning as ‘true’
BarelySmooth
Scratcher
1000+ posts

784 contains letters

Are you trying to check if the answer contains letters?

Then, have you tried setting the variable “lettercheck” to zero before going through the loop? Otherwise, the variable will never become zero and will go on to values higher than 52 (which the list doesn't have). When I opened the project, the value of lettercheck was 93. Since there weren't 93 items in the list of lettters, you might have seen bugs.

set [lettercheck v] to [0] //This is done to prevent the value from going more than 52 if we run it multiple times
repeat (52)
change [lettercheck v] by (1)
...
end

Hope this helped

Last edited by BarelySmooth (Sept. 28, 2021 03:45:15)

mecodetwo
Scratcher
100+ posts

784 contains letters

BarelySmooth wrote:

Are you trying to check if the answer contains letters?

Then, have you tried setting the variable “lettercheck” to zero before going through the loop? Otherwise, the variable will never become zero and will go on to values higher than 52 (which the list doesn't have). When I opened the project, the value of lettercheck was 93. Since there weren't 93 items in the list of lettters, you might have seen bugs.

set [lettercheck v] to [0] //This is done to prevent the value from going more than 52 if we run it multiple times
repeat (52)
change [lettercheck v] by (1)
...
end

Hope this helped
I am unsure if i set lettercheck to 0, but thank you so much!!!!
mecodetwo
Scratcher
100+ posts

784 contains letters

mecodetwo wrote:

BarelySmooth wrote:

Are you trying to check if the answer contains letters?

Then, have you tried setting the variable “lettercheck” to zero before going through the loop? Otherwise, the variable will never become zero and will go on to values higher than 52 (which the list doesn't have). When I opened the project, the value of lettercheck was 93. Since there weren't 93 items in the list of lettters, you might have seen bugs.

set [lettercheck v] to [0] //This is done to prevent the value from going more than 52 if we run it multiple times
repeat (52)
change [lettercheck v] by (1)
...
end

Hope this helped
I am unsure if i set lettercheck to 0, but thank you so much!!!!
I just looked, and what I had is,
when this sprite clicked
set [lettercheck v] to [0]
ask [What's your password?] and wait
...

Last edited by mecodetwo (Sept. 28, 2021 22:11:25)

D-ScratchNinja
Scratcher
1000+ posts

784 contains letters

It might be comparing it to a list item that doesn't exist (such as item 0). In that case, it would be checking if “784” contains “” (a nothing), which is… technically true, because if “” contains a nothing, then “784” contains a nothing.
mecodetwo
Scratcher
100+ posts

784 contains letters

But it (hopefully) can't be, because in my code it says,
repeat (52)
change [lettercheck v] by (1)
...
end
BarelySmooth
Scratcher
1000+ posts

784 contains letters

mecodetwo wrote:

I just looked, and what I had is,
when this sprite clicked
set [lettercheck v] to [0]
ask [What's your password?] and wait
...
Ohhhh, Sorry I wan't clear earlier You have to set the variable lettercheck to zero every time you iterate over a list.


(this screenshot is from the savebutton sprite)

Last edited by BarelySmooth (Sept. 29, 2021 08:34:21)

mecodetwo
Scratcher
100+ posts

784 contains letters

BarelySmooth wrote:

mecodetwo wrote:

I just looked, and what I had is,
when this sprite clicked
set [lettercheck v] to [0]
ask [What's your password?] and wait
...
Ohhhh, Sorry I wan't clear earlier You have to set the variable lettercheck to zero every time you iterate over a list.


(this screenshot is from the savebutton sprite)
soo, should i put,
ask [whats your password] and wait
set [letercheck v] to [0]
...
? (i cant see screenshot)

Last edited by mecodetwo (Sept. 29, 2021 14:43:49)

mecodetwo
Scratcher
100+ posts

784 contains letters

mecodetwo wrote:

BarelySmooth wrote:

mecodetwo wrote:

I just looked, and what I had is,
when this sprite clicked
set [lettercheck v] to [0]
ask [What's your password?] and wait
...
Ohhhh, Sorry I wan't clear earlier You have to set the variable lettercheck to zero every time you iterate over a list.


(this screenshot is from the savebutton sprite)
soo, should i put,
ask [whats your password] and wait
set [letercheck v] to [0]
...
? (i cant see screenshot)
never mind, im stupid, it checks for letters twice, i have
if <...> then 
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end


else
...
end
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end
but i should have
if <...> then 
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end


else
...
end
set [lettercheck v] to [0]
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end

Last edited by mecodetwo (Sept. 29, 2021 14:44:20)

BarelySmooth
Scratcher
1000+ posts

784 contains letters

mecodetwo wrote:

never mind, im stupid, it checks for letters twice, i have
if <...> then 
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end


else
...
end
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end
but i should have
if <...> then 
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end


else
...
end
set [lettercheck v] to [0]
if <(784)contains(item (lettercheck :: variables) of [leters v] :: list) :: operators> then

end
That's right! I hope it works for you now

Also, this was the screenshot I posted earlier (I reuploaded it on scratch in case you were unable to access cubeupload images):

Last edited by BarelySmooth (Sept. 29, 2021 14:51:22)

mecodetwo
Scratcher
100+ posts

784 contains letters

@BarelySmooth thank you so much!!!!! it works now.
when I'm not dumb any more and @BarelySmooth 's help makes sense :: events :: hat
reply [thank you!!] :: looks
be happy [and finish thing ] :: custom

define be happy (and finish thing)
repeat until <thing finished :: control>
watch tutorial for 2 seconds :: control
build the exact same thing in scratch :: control
end

Powered by DjangoBB