Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift for Loop inside a while Loop

// program to display 7 days of 2 weeks
var weeks = 2
var i = 1

// outer while loop
while (i <= weeks){
  print("Week: (i)")

  // inner for loop
  for day in 1...7{
      print("  Day:  (day)")
    }

    i = i + 1
}
Source by www.hackingwithswift.com #
 
PREVIOUS NEXT
Tagged: #Swift #Loop #Loop
ADD COMMENT
Topic
Name
5+5 =