Discuss Scratch

chocolatepenguin
Scratcher
1000+ posts

Difference counting

I have created a project that counts the difference between different items in a list, and the difference has to be 1 for the answer to be added to the list.
The diffence between “Moon” and “Moot” is obviously 1, but the program says it is 4. What is wrong?
The project can be found here: http://scratch.mit.edu.ezproxyberklee.flo.org/projects/10132346/
chocolatepenguin
andre_rifaut
Scratcher
100+ posts

Difference counting

Well you get a nasty error in your code.
It would be interesting to tell that to the Scratch team with a suggestion in: http://scratch.mit.edu.ezproxyberklee.flo.org/discuss/1/

I'm used to code with scratch and it took me some time to find this nasty error.

Actually, you used the “green” block “length of” coming from the “Operators” section.
You have to use the “red” block “length of” coming from the “Data” section.

The green one, when used with a list variable do not give you the length of the list, but the length of all list content (i.e. concatenated).

Your project idea seems very interesting.

chocolatepenguin
Scratcher
1000+ posts

Difference counting

Thanks-I never noticed that list block.
I got the idea from doing this on paper with my family.
chocolatepenguin

P.S. I took he project down for a minute or two to make that change. It's back up now.

Last edited by chocolatepenguin (May 12, 2013 11:54:23)

Powered by DjangoBB