example: my_list(1) = 10.0 (is there a way to do this?)
my_list = list(1.0, 10.0, 100.0, 1000.0, 10000.0)
I'm trying to create a for loop that prints each index separately, so basically I want to cycle through each index and print it
example: my_list(1) = 10.0 (is there a way to do this?)
my_list = list(1.0, 10.0, 100.0, 1000.0, 10000.0)
I'm trying to create a for loop that prints each index separately, so basically I want to cycle through each index and print it
Just iterate over it:
for element in my_list:
print(element)
If you want to print the indices as well, use enumerate()
:
for index, element in enumerate(my_list):
print(index, element)