-1

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

Wes
  • 413
  • 1
  • 4
  • 9

2 Answers2

0

If you want the non-Pythonic way

for i in range(len(my_list)):
    print(my_list[i])
chowsai
  • 565
  • 3
  • 15
-1

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)
Josh Karpel
  • 2,110
  • 2
  • 10
  • 21