your solution is wrong in exercise Hands-On Lab: Loops
Question
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. The list PlayListRatings is given by: PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]
My code :PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]
i = 1
Rating = PlayListRatings[0]
while not(Rating < 6):
print(Rating)
Rating = PlayListRatings[i]
i = i + 1
print("the loops stops here.")
output: 10
9.5
10
8
7.5
the loops stops here.
your code :PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]
i = 0
Rating = PlayListRatings[0]
while(i < len(PlayListRatings) and Rating >= 6):
print(Rating)
Rating = PlayListRatings[i]
i = i + 1
output:10 <--------------- (this value is repeating itself)
10
9.5
10
8
7.5