Snippets Collections
colors = ['red', 'green', 'blue']
for idx, color in enumerate(colors):
	print(idx, color)
> 0 red
> 1 green
> 2 blue
JS

favMovies.forEach(function(favMovie) {
  console.log('I really like the movie', favMovie)
})
JavaScript

for (let i=0; i < arrayName.length; i++){
  console.log(arrayName[i])
}

i.e.):

movies = ['legally blonde', 'Ms. & Ms. Smith', 'The Incredibles'];

for (let i=0; i < movies.length; i++){
  console.log(movies[i])
}

Python

for singular_array_name in array_name_pluralized:
	print(singular_array_name)

i.e.):

movies = ['legally blonde', 'Ms. & Ms. Smith', 'The Incredibles']

for movie in movies:
	print(movie)
star

Sat Jan 15 2022 19:30:51 GMT+0000 (Coordinated Universal Time)

#python #iteration #enumerate #list
star

Sat Jan 15 2022 19:15:38 GMT+0000 (Coordinated Universal Time)

#python #javascript #iteration #foreach
star

Sat Jan 15 2022 19:01:04 GMT+0000 (Coordinated Universal Time)

#python #javascript #array #list #forloop #iteration

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension