MulaiMulai sekarang secara gratis

Looping through a list

You're doing a trial run of cooking the pasta dish. First, you need to list all your ingredients to make sure you have everything ready.

Then, you'll add them one by one as you cook — seven ingredients in total.

Latihan ini adalah bagian dari kursus

Introduction to Python for Developers

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

ingredients = ["fusilli", "tomatoes", "garlic", "basil", "olive oil", "salt"]

# Loop through each ingredient in the list
for ____ in ____:
    print(item)
Edit dan Jalankan Kode