Day 05

Photo by Clay Banks on Unsplash

Day 05

looping

Loops do repetitive tasks for you.

for in loop

The easiest way to iterate through a list or string.


for iterator_variable in list:
  do_something()

for-in with range


upper_limit = 5
for i in range(0, upper_limit):
  print(i)

#0
#1
#2
#3
#4

for-in over a list


my_list = ['dog', 'cat', 'panda', 4, 1, 'dolphin', 9]
for ele in my_list :
  print(ele)

#dog
#cat
#panda
#4
#1
#dolphin
#9

Iterating over index


my_list = ['dog', 'cat', 'panda', 4, 1, 'dolphin', 9]
for index in range(len(my_list)) :
  print(my_list[index])

#dog
#cat
#panda
#4
#1
#dolphin
#9

Project - Password Generator!

05-op.png

05-ip.png

05-ip2.png