Pass Statement in For Loops

Pass Statement in For Loops

  • Is used to skip loops or structures that require later completion of code

    • Example: you need to write the loop next week and you need a place holder for that

my_list = ['computer', 'car', 'bottle', 'tv']

for item in my_list: # Will return an indentetion error if empty
	pass # Used of later completion of code

# do other stuff
# do other code
# etc ...

You can also have the list in the for loop directly:

for item in ['computer', 'car', 'bottle', 'tv']:
	print(item)

Last updated