In Python 3 we cannot increment a variable directly with "++" before or after this variable.
We have to add + 1 on the variable to increment it.
That's a bit annoying but life is life.
In this tutorial we are going to see examples of the Python 3 statements.
We use the while statement to iterate through a number. An int for example.
i = 0 end = 10 while i < end: print(i) i = i + 1
0 1 2 3 4 5 6 7 8 9
We use the for statement to iterate through something that have data such a string (has characters), an or a list (have items) for example.
i = 0 myString = "Hello World!" for i in myString: print(i)
H e l l o W o r l d !
i = 0 myList = ["Hello", 8, "World", 99] for i in myList: print(i)
Hello 8 World 99
Easy but useful.
Add new comment