0
why we use mostly while loop instead of for loop in python
4 Answers
+ 2
@donkeyhot
while arduino_pin_current < max_current:
?
+ 2
Edit1: While loop is used when we stop looping on some condition or in an infinite while: True loop. In other cases use for loop:
i = 0
while i<10: #C-style
#do smth
i += 1
for i in range(10): #pythonic
#do smth
+ 1
And if you're talking about the most guys here, that use while loops mostly. That's only because they are just learning basics of python and write their programs
C-style. Don't be like them. Be smart. Use for loops and other python possibilities.
0
@Kirk Schafer
for arduino_pin_current in range(maxcurrent):
pass
Ok, i get it. You're right. While loop is also used when we stop looping on some condition. I just meant for is more common.