So for a list that has 1000 elements, I want to loop from 400 to 500. How do you do it?
I don’t see a way by using the for each and for range techniques.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are working with an iterable instead of a list, you should use itertools:
If you need to loop over
thousand[500], then use 501 as the latter index. This will work even ifthousand[501]is not a valid index.