godot for loop
# loop for n = 0 to 7
for n in range(8):
print(n)
# loop for n = 10 to 12
for n in range(10,13):
print(n)
# count down from 10 to 1
for n in range(10,0,-1):
print(n)
# loop for n = 2,4,6,8 in steps of 2
for n in range(2,9,2):
print(n)
# Iterate over string (array of characters)
for ch in "Hello":
print(ch)
# Iterate over an array of numbers
for x in [3,6,8,9]:
print(x)
# Iterate over items of a dictionary
var dict = { "x": 1, "y": 2, "z": 3 }
for key in dict:
# Insert the key and value into a text string
print("index: %s, value: %d" % [key, dict[key]])
# Using continue and break statements
for i in range(9):
# Skip numbers below 3
if i < 3:
continue
# Break out of the loop for numbers above 5
if i > 5:
break
print(i)
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line