Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

nums = [2,7,11,15]

for i in nums:
    for j in nums:
        print(j)

>Solution :

Does it solve your problem?

nums = [2, 7, 11, 15]

for i in range(len(nums)):
    for j in range(i, len(nums)):
        print(j)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading