Discuss Scratch
- Discussion Forums
- » Suggestions
- » Add a For loop
- destroyer489
- Scratcher
28 posts
Add a For loop
so I use Python, C++, and Java a lot and have the great functionality of the for-loop. this is a loop that repeats a certain number of times while having an index this is especially useful for lists and tuples. more documentation can be found here. this type of loop is incredibly useful and would be a fantastic addition to the scratch library
- -Accio-
- Scratcher
1000+ posts
Add a For loop
This has been suggested so many times that I can't even find an oldest duplicate.
Hi There! I'm -Accio-
I am currently attending university for a Bachelor's of Science in Chemistry.
“If you are not part of the solution, you are part of the precipitate”
- ResExsention
- New to Scratch
1000+ posts
Add a For loop
set [index v] to [0]
repeat (10)
change [index v] by (1)
Do things...
end
Uh, close, but not quite.
set [index v] to [0]
set [target v] to [whatever, even another variable]
repeat (target)
change [index v] by (1)
...
end
Semi-support though. For loops are actually quite useful.
Last edited by ResExsention (May 22, 2019 01:57:50)
Infrequently active.
It feels weird to see how far we've come. I hope you're well, wherever you are!
- groko13
- Scratcher
100+ posts
Add a For loop
set [index v] to [0]
repeat (10)
change [index v] by (1)
Do things...
end
Uh, close, but not quite.set [index v] to [0]
set [target v] to [whatever, even another variable]
repeat (target)
change [index v] by (1)
...
end
Semi-support though. For loops are actually quite useful.
Actually:
set [index v] to [some #]
repeat until <(index) = [some #]>
do stuff
change [index v] by some #
end
While this is a suitable workaround, I would much prefer (and fully support the addition of) for loops because they make the code neater and use a temporary variable rather than requiring a separate variable.
-This post was brought to you by me.
- MiniCoder11
- Scratcher
100+ posts
Add a For loop
Scratch actually already comes with a built in “for loop”. It just isn't accessible through the main editor panel. To get your hands on this incredibly useful block, just backpack it from this project: https://scratch.mit.edu/projects/343427953/.
I hope that helped!
I hope that helped!
Please let me know if there is anything else I can do to help
- Nambaseking01
- Scratcher
1000+ posts
Add a For loop
Unfortunately, this seems to be a duplicate topic!
Here are all of the duplicates I found sorted from oldest to newest:
https://scratch.mit.edu/discuss/topic/11712/ (July 24, 2013)
https://scratch.mit.edu/discuss/topic/19763/ (November 7, 2013)
https://scratch.mit.edu/discuss/topic/44424/ (July 3, 2014)
https://scratch.mit.edu/discuss/topic/46758/ (July 23, 2014)
https://scratch.mit.edu/discuss/topic/81652/ (January 16, 2015)
https://scratch.mit.edu/discuss/topic/104164/ (April 3, 2015)
https://scratch.mit.edu/discuss/topic/204415/ (June 16, 2016)
https://scratch.mit.edu/discuss/topic/275054/ (August 30, 2017)
https://scratch.mit.edu/discuss/topic/305375/ (June 30, 2018)
Here are all of the duplicates I found sorted from oldest to newest:
https://scratch.mit.edu/discuss/topic/11712/ (July 24, 2013)
https://scratch.mit.edu/discuss/topic/19763/ (November 7, 2013)
https://scratch.mit.edu/discuss/topic/44424/ (July 3, 2014)
https://scratch.mit.edu/discuss/topic/46758/ (July 23, 2014)
https://scratch.mit.edu/discuss/topic/81652/ (January 16, 2015)
https://scratch.mit.edu/discuss/topic/104164/ (April 3, 2015)
https://scratch.mit.edu/discuss/topic/204415/ (June 16, 2016)
https://scratch.mit.edu/discuss/topic/275054/ (August 30, 2017)
https://scratch.mit.edu/discuss/topic/305375/ (June 30, 2018)
Hey there! My name is Nammy. I'm a male Forum Helper and Scratch Wiki Editor.
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
Profile | Test Account | Talk with me here! | Griffpatch is quitting Scratch?!
- Harakou
- Scratcher
1000+ posts
Add a For loop
Yeah, there are uh, a lot of these. It's a pretty common and useful construct. I'm not quite sure why we don't have one, though I presume the idea has been floated at some point. Most likely, since it's a convenience factor, I think it was probably deemed not entirely necessary. Unfortunately, this seems to be a duplicate topic!
Here are all of the duplicates I found sorted from oldest to newest:
https://scratch.mit.edu/discuss/topic/11712/ (July 24, 2013)
https://scratch.mit.edu/discuss/topic/19763/ (November 7, 2013)
https://scratch.mit.edu/discuss/topic/44424/ (July 3, 2014)
https://scratch.mit.edu/discuss/topic/46758/ (July 23, 2014)
https://scratch.mit.edu/discuss/topic/81652/ (January 16, 2015)
https://scratch.mit.edu/discuss/topic/104164/ (April 3, 2015)
https://scratch.mit.edu/discuss/topic/204415/ (June 16, 2016)
https://scratch.mit.edu/discuss/topic/275054/ (August 30, 2017)
https://scratch.mit.edu/discuss/topic/305375/ (June 30, 2018)
- Discussion Forums
- » Suggestions
- » Add a For loop