How to loop from a particular index of an array in Python?

I am using a nested loop, and I want my inner loop to start from the index of the outer loop.

How can I implement this?

I want j to run from i till the end of the array.

nums = [2,7,11,15]

for i in nums:
    for j in nums:

>Solution :

Does it solve your problem?

nums = [2, 7, 11, 15]

for i in range(len(nums)):
    for j in range(i, len(nums)):

Leave a Reply