Main content
Course: Intro to computer science - Python?>?Unit 3
Lesson 4: Loop control flowTrace compound while loops
Problem
A music app runs a loop to play through songs in a playlist.
import player
songs_played = 0
playlist_length = player.get_playlist()
autoplay = "on"
while songs_played < playlist_length or autoplay == "on":
player.play_next_song()
songs_played = songs_played + 1
autoplay = input("Autoplay? ")
How do the variables in the loop condition affect the number of iterations?