Iteration

3 / 5

Lists are sequences of values that can be processed using a loop. You can use a for loop to go through each value directly:

fruits = ['apple', 'banana', 'coconut']
for val in arr:
  print(val)

This prints all three fruits, each on their own line. If you need both index and value, you can use enumerate:

for idx,val in enumerate(arr):    
  print(f"index {idx} contains {val}")

These patterns are useful when you're processing, transforming, or analyzing a sequence of data step by step.

List iteration

Write a function num_increases with a parameter closes of daily closing prices on a certain stock. The function should return how many times the stock price went up in value during the day.

Congratulations!

You passed the !

Welcome!

Would you like a guided tour on how to use Vibewise?

Your email has been verified!