Useful Trick: How to configure a list of Digital Pins using a For loop in Python

In the last entry on our Community Projects Hub on Hackster, the author used a nice trick to configure the pins with a For loop.

for loops are traditionally used when you have a block of code which you want to repeat a fixed number of times. The Python for statement iterates over the members of a sequence in order, executing the block each time. [For Loop on Python wiki]
Here’s the code:
`pumps   = [D5, D3, D1] # list of pump control pins
valves = [D4, D2, D0] # list of valve control pins

set the pins as OUTPUT, default state is OFF

for pin in pumps+valves:

More info:<br><ul><li><a rel="nofollow" href="">For Statements</a></li><li><a rel="nofollow" href="">pinMode()</a></li><li><a rel="nofollow" href="">digitalWrite()</a></li></ul>Happy coding!