![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | JulioYagami |
I ever see codes like:
for i in 10:
# do something
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | JulioYagami |
I ever see codes like:
for i in 10:
# do something
![]() |
Reply From: | kidscancode |
for
is used to create a loop that iterates through a range of values. The most common form is a loop to count through numeric values:
for i in range(10):
print(i)
This would print the numbers from 0 through 9.
The form you quoted above is an abbreviation. If you omit the range()
function GDScript will assume it.
Note you can also iterate through arrays, strings, and dictionaries as well.
See here for more details: