Run a for loop for each item in a list

for variable in list_name:
  print variable

Run a for loop for each item in a dictionary

webster = {
  "Aardvark" : "A star of a popular children's cartoon show.",
  "Baa" : "The sound a goat makes.",
  "Carpet": "Goes on the floor.",
  "Dab": "A small amount."
}

for words in webster:
  print webster[words]

Run a for loop on the first ‘x’ amount of variables

count = 0
x = 10

for variable in list_name:
  if count >= x:
    echo "variable"
    count += 1

Leave a Reply

Your email address will not be published. Required fields are marked *