iteration Archive

Iteration in Python (Part II)

For Loop Sometimes we want to loop through a set of things such as a list of words, the lines in a file or a list of numbers. When we have a list of things to loop through, we can construct a definite loop using a for statement. We call the while statement an indefinite loop because it

Iteration in Python (Part I)

Updating Variables A common pattern in assignment statements is an assignment statement that updates a variable – where the new value of the variable depends on the old. x = x+1 This means “get the current value of x, add one, and then update x with the new value.” If you try to update a variable that

Loops in Java

Loops in Java To repeat a set of statements more then one time without using any structure is pretty hard. For example : if we want to display 100 times “Welcome to Java” on the screen. The following line we have to write 100 times to achieve results. System.out.println("Welcome to java"); Instead of repeating hundred