Log in from a computer to take this course

You'll need to log in from a computer to start Learn Swift. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn
for _ in 1...10 { print("Great job!") } print("Now time to review loops!")

The above syntax should now look familiar!

In this lesson, we went over:

  • Manually repeating tasks.
  • for-in loops are used to iterate over collection items like ranges and strings.
  • stride() creates a range that we can customize.
  • _ usage when we don’t need to use the placeholder variable.
  • continue allows us to move on to the next value.
  • break stops the loop before the stopping condition is met.
  • while loops are used when we don’t know how many times we’re looping.

Instructions

1.

If you want to challenge yourself:

  • Create a loop that iterates from 1 to 100 that prints out whether the current number in the iteration is even or odd.
  • Use a loop to determine if a number is a prime number.
  • Loop through a string and count how many characters are in it.
  • Recreate the follow pattern using loops:
* ** *** ****

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?