We then briefly explained what the two built-in python methods, range() and enumerate(), do in for loops. We went over the basic syntax that makes up a for loop and how it works. The variable i assumes the value 1 on the first iteration, 2 on the second, and so on. I hope you enjoyed this basic introduction to the for loop in Python. Here, the body of the loop is executed ten times. The line enumerate(groceries) lets us iterate through the sequence and keep track of the index of the value and the value itself. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |