I know that I can use something like string[3:4] to get a substring in Python, but what does the 3 mean in somesequence[::3]?
I know that I can use something like string[3:4] to get a substring in
Share
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.
it means ‘nothing for the first argument, nothing for the second, and jump by three’. It gets every third item of the sequence sliced.
Extended slices is what you want. New in Python 2.3