belongs to collection: Python Loop Exercises
Given:
my_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
Note: list index always starts at 0
Expected output:
20 40 60 80 100
Hint:
Use list slicing. Using list slicing, we can access a range of elements from a list
Solution:
my_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] # stat from index 1 with step 2( means 1, 3, 5, an so on) for i in my_list[1::2]: print(i, end=" ")
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use list slicing. Using list slicing, we can access a range of elements from a list
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer