+ 1

What kind of use [for], [while] in Python?

I don't understand well.

15th Sep 2018, 5:23 AM
Minseok Choi
3 Respuestas
+ 10
See 'for' and 'while' are loops in Python. Loops executes the block of code until a condition is satisfied. When the condition becomes false, the statement immediately after the loop is executed. The statements inside them are repeatedly executed, as long as the condition holds.
15th Sep 2018, 6:07 AM
Nova
Nova - avatar
+ 7
'for' iterates (goes through one thing at a time) over a sequence like a list or a string or a range of numbers, and makes the loop execute each time. 'while' makes the loop execute as long as the condition is True. e.g. for x in "abc": print(x) outputs: a b c i = 0 while i < 3: print("abc"[i]) i = i + 1 outputs: a b c
15th Sep 2018, 11:36 AM
David Ashton
David Ashton - avatar
+ 2
for is count controlled whereas while is condition controlled.
15th Sep 2018, 6:29 PM
benjamin