# Use for loop to change the elements in list

squares = ['red', 'yellow', 'green', 'purple', 'blue']

for i in range(0, 5):
    print("Before square ", i, 'is',  squares[i])
    squares[i] = 'white'
    print("After square ", i, 'is',  squares[i])
    
    
# While Loop Example

dates = [1982, 1980, 1973, 2000]

i = 0
year = dates[0]

while(year != 1973):    
    print(year)
    i = i + 1
    year = dates[i]
    

print("It took ", i ,"repetitions to get out of loop.")


# Write a while loop to display the values of the Rating of an album playlist stored in the list PlayListRatings. If the score is less than 6, exit the loop.

PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]
i = 1
Rating = PlayListRatings[0]
while(i < len(PlayListRatings) and Rating >= 6):
    print(Rating)
    Rating = PlayListRatings[i]
    i = i + 1
    
    
# Write a while loop to copy the strings 'orange' of the list squares to the list new_squares. Stop and exit the loop if the value on the list is not 'orange':  
squares = ['orange', 'orange', 'purple', 'blue ', 'orange']
new_squares = []
i = 0
while(i < len(squares) and squares[i] == 'orange'):
    new_squares.append(squares[i])
    i = i + 1
print (new_squares)
9826fe36e6c1fe907eebb46791426e51885b0149
<mask token>

<mask token>
for i in range(0, 5):
    print('Before square ', i, 'is', squares[i])
    squares[i] = 'white'
    print('After square ', i, 'is', squares[i])
<mask token>
while year != 1973:
    print(year)
    i = i + 1
    year = dates[i]
print('It took ', i, 'repetitions to get out of loop.')
<mask token>
while i < len(PlayListRatings) and Rating >= 6:
    print(Rating)
    Rating = PlayListRatings[i]
    i = i + 1
<mask token>
while i < len(squares) and squares[i] == 'orange':
    new_squares.append(squares[i])
    i = i + 1
print(new_squares)

squares = ['red', 'yellow', 'green', 'purple', 'blue']
for i in range(0, 5):
    print('Before square ', i, 'is', squares[i])
    squares[i] = 'white'
    print('After square ', i, 'is', squares[i])
dates = [1982, 1980, 1973, 2000]
i = 0
year = dates[0]
while year != 1973:
    print(year)
    i = i + 1
    year = dates[i]
print('It took ', i, 'repetitions to get out of loop.')
PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]
i = 1
Rating = PlayListRatings[0]
while i < len(PlayListRatings) and Rating >= 6:
    print(Rating)
    Rating = PlayListRatings[i]
    i = i + 1
squares = ['orange', 'orange', 'purple', 'blue ', 'orange']
new_squares = []
i = 0
while i < len(squares) and squares[i] == 'orange':
    new_squares.append(squares[i])
    i = i + 1
print(new_squares)

# Use for loop to change the elements in list

squares = ['red', 'yellow', 'green', 'purple', 'blue']

for i in range(0, 5):
    print("Before square ", i, 'is',  squares[i])
    squares[i] = 'white'
    print("After square ", i, 'is',  squares[i])
    
    
# While Loop Example

dates = [1982, 1980, 1973, 2000]

i = 0
year = dates[0]

while(year != 1973):    
    print(year)
    i = i + 1
    year = dates[i]
    

print("It took ", i ,"repetitions to get out of loop.")


# Write a while loop to display the values of the Rating of an album playlist stored in the list PlayListRatings. If the score is less than 6, exit the loop.

PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]
i = 1
Rating = PlayListRatings[0]
while(i < len(PlayListRatings) and Rating >= 6):
    print(Rating)
    Rating = PlayListRatings[i]
    i = i + 1
    
    
# Write a while loop to copy the strings 'orange' of the list squares to the list new_squares. Stop and exit the loop if the value on the list is not 'orange':  
squares = ['orange', 'orange', 'purple', 'blue ', 'orange']
new_squares = []
i = 0
while(i < len(squares) and squares[i] == 'orange'):
    new_squares.append(squares[i])
    i = i + 1
print (new_squares)