- while loop is condition dependent and does not necessarily need the content to be evaluated
- for loop requires content to iterate over
Similarity:
- both can iterate over a list or structure, but you must define your content to iterate through beneath the while condition whereas for loops define the content index and type at start
The similarities between for loop and while loop are :-
Both can iterate over a list or structure, but you must define your content to iterate through beneath the while condition whereas for loops define the content index and type at start.
Their similarity is that both "while" and "for" are used for repeating a loop
Answers & Comments
Difference:
- while loop is condition dependent and does not necessarily need the content to be evaluated
- for loop requires content to iterate over
Similarity:
- both can iterate over a list or structure, but you must define your content to iterate through beneath the while condition whereas for loops define the content index and type at start
The similarities between for loop and while loop are :-
Both can iterate over a list or structure, but you must define your content to iterate through beneath the while condition whereas for loops define the content index and type at start.
Their similarity is that both "while" and "for" are used for repeating a loop