Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3309882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:41:37+00:00 2026-05-17T21:41:37+00:00

If I have the list: lista=[99, True, Una Lista, [1,3]] What does the following

  • 0

If I have the list:

lista=[99, True, "Una Lista", [1,3]]

What does the following expression mean?

mi_var = lista[0:4:2]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:41:38+00:00Added an answer on May 17, 2026 at 9:41 pm

    The syntax lista[0:4:2] is called extended slice syntax and returns a slice of the list consisting of the elements from index 0 (inclusive) to 4 (exclusive), but only including the even indexes (step = 2).

    In your example it will give [99, "Una Lista"]. More generally you can get a slice consisting of every element at an even index by writing lista[::2]. This works regardless of the length of the list because the start and end parameters default to 0 and the length of the list respectively.

    One interesting feature with slices is that you can also assign to them to modify the original list, or delete a slice to remove the elements from the original list.

    >>> x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    >>> x[::2] = ['a', 'b', 'c', 'd', 'e']   # Assign to index 0, 2, 4, 6, 8
    >>> x
    ['a', 1, 'b', 3, 'c', 5, 'd', 7, 'e', 9]
    >>> del x[:5]                            # Remove the first 5 elements
    >>> x
    [5, 'd', 7, 'e', 9]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two list: list_a = [<User: x>, <User: y>] list_b = [False, True]
We have this JAXB annotation: @XmlElement(name = Strategy, required = true) protected List<Strategy> strategy;
I have two list: set lista {5 6} set listb {8 9} and the
I have a List of keys say 'ListA'. And a map of keys &
I have list definition. <ListInstance Title=tv2 - ListInstance3 OnQuickLaunch=TRUE TemplateType=10002 Url=Lists/tv2 - tips status
I have a list like this <ul data-role=listview id=list data-filter=true></ul> it looks good on
I have a list l:List[T1] and currently im doing the following: myfun : T1
I have List List<MyType> , my type contains Age and RandomID Now I want
I have a list: List(Of String) I want to filter it with LINQ. I
Lists say I have a list List<int> {1,2,3,4,5} Rotate means: => {2,3,4,5,1} => {3,4,5,1,2}

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.