เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Loops and enumerate

Now that you've built a for loop which can iterate over a vector, let's extend this for loop using the enumerate function to return both the index and the value of everything inside the vector stock_tickers.

Keep in mind that for every element of stock_tickers we want to print the index, followed by a space, followed by the value.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Intermediate Julia

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Use enumerate to print the corresponding index of each value to the console.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Loop over stock_tickers printing the index and item
for (____, ____) in ____(stock_tickers)
	println(____, " ", ____)
end
แก้ไขและรันโค้ด