Different Python statements can be substituted for the ones used in the previous example. Experimenting in this way can help you to get used to using different approaches when structuring your Python code.
For example, the for loops could be swapped for while loops.
In this section |
See also |
colors = ['red','green', 'blue','pink','orange','gray','purple','magenta']
if inputs[0].changed_get():
for i in range(len(outputs)):
outputs[i].string_set(colors[i])
else:
for i in range(len(outputs)):
outputs[i].string_set(" ")
colors = ['red','green', 'blue','pink','orange','gray','purple','magenta']
if inputs[0].changed_get():
i = 0
while i < len(outputs):
outputs[i].string_set(colors[i])
i = i + 1
else:
i= 0
while i < len(outputs):
outputs[i].string_set(" ")
i = i + 1