The borders for ''while'' command

Hello!

Please sorry for my very poor knowledge in this scripting area, this python is new for me:

So, i noticed that i need to put double point ‘’:’’ ( sorry, i don’t know the translation for this word ) at very end of the ‘‘if’’, ‘‘else’’, ‘‘while’’ etc. commands.
The problem is: i don’t know where the ‘‘while’’ command ends. ( In other languages i think it’s ‘’{’’ and ‘’}’’ )

Here is this very short script:

import bpy
from bpy import context
createNewCube = bpy.ops.mesh.primitive_cube_add

cursor = context.scene.cursor_location
xsize = 0.5
ysize = 0.5
zsize = 0.5

x = cursor.x
y = cursor.y
z = cursor.z

startV = 1.0
endV = 5.0

while startV < endV:

createNewCube(location=(x,y,z))
bpy.ops.transform.resize(value=(xsize, ysize, zsize))

startV += 1.0

I want to spawn cubes, until the ‘‘startV’’ reaches the value 5.0, but Blender crashes, because it spawns a lot of cubes.
The goal is to isolate those 2 rows i have under the ‘‘while startV < endV:’’ command from the ‘‘startV += 1.0’’

Thank you for reading this, sorry if i did any english grammar mistakes, it’s not my native language.

The indention of the lines after the while statement determine what is included in the loop:


import bpy
from bpy import context
createNewCube = bpy.ops.mesh.primitive_cube_add


cursor = context.scene.cursor_location
xsize = 0.5
ysize = 0.5
zsize = 0.5


x = cursor.x
y = cursor.y
z = cursor.z


startV = 1.0
endV = 5.0


while startV &lt; endV:
     createNewCube(location=(x,y,z))
     bpy.ops.transform.resize(value=(xsize, ysize, zsize))
     startV += 1.0

startV += 1.0 should have the same indention as the two lines before it, so that 1 gets added to startV each loop.

Python uses indentation (“in-toothing”). Put some spaces before every line after ‘while’. No longer put those spaces to end the ‘while’ block.

Wooow, thank you, this works now!
Without you i would never figured it out.

EDIT1: Thank you Sjoerd too for your reply, i will watch for those rows and spaces :slight_smile:
Marked this as [SOLVED], but you can reply if you want.

Thanks for helping guys.

“:” is called colon in english :slight_smile: