2021-12-05

How to iterate the range of numbers in a list?

So this may sound like a dumb question and maybe I'm overthinking this, but I'm struggling to figure out how to iterate the range of numbers in a list. Say I have a list of numbers [100, 500, 1000]. I don't necessarily want to iterate through this list, but I want to iterate through the values if that makes sense. So I'm guessing I would iterate through the list first, but then I would need to create another loop for the values?

   for i in mylist:
        for j in range(0, mylist[i]):
             do something

I feel like this may be inefficient but would this be the way to do that?



from Recent Questions - Stack Overflow https://ift.tt/3DmLhFV
https://ift.tt/eA8V8J

No comments:

Post a Comment