Download presentation
Presentation is loading. Please wait.
Published bySurya Iskandar Modified over 5 years ago
1
Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops
CS 1110 Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops
3
Last time While loops Strategies for repetitive code Needs 3 things
Condition Something to be repeated Adjust the condition Strategies for repetitive code Top down Start with the loop Bottom up Start with everything else and repeat
4
Today: For loops Similar to while
Does not require a condition Instead requires a collection Almost everything you can do with while you can do with for What might you not be able to do with for? Keywords: for in
5
Syntax for something in collection: # Repeat this code For Something
Iterate through whatever you give it Something Assigned in the loop In Specifies the set of iteration Collection Whatever we want to loop through
6
Collections (so far) Strings Ranges Lists Tuples*
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.