Python Programming Tutorial - 10 - Slicing

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
97,939
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Apr 19, 2009

Category:

Science & Technology

Tags:

License:

Standard YouTube License

  • likes, 8 dislikes

Link to this comment:

Share to:

Top Comments

  • @bubbleheadft Wrong. You probably just forgot to add "0" to the first section of your list.

    "Typing [4:9]..." This will give you what's inside index 4 and up to (but does not include) 9. The index number 4 is actually the 5th index in the list. This is because the starting index is 0 on most programming languages.

    I use 2.7.2 and everything works perfectly just perfect - so far.

  • @bubbleheadft I'm using python 2.7.2 and typing [4:9] gives me the result: [4,5,6,7] as he says. Before vote up this comment check which result you have.

see all

All Comments (294)

Sign In or Sign Up now to post a comment!
  • example=[1,2,4,7,5]

    example[-1:0:-1]

    Output

    [5, 7, 4, 2]

    What is wrong here?

    the way I see it, count from -1(last element) to 0(first element) using -1(backwords with 1 increment) .. but then why first element gets skipped?

    This code example[::-1] works perfectly fine and gives out all numbers in rev order

  • [10:0:02]

    [4:]

    anything like that doesnt work for me.

  • ur a better teacher than google

  • hi, nice tut's but i dont find them usefull... plz could yu make a tutorial of how to make a bot that could maybe link to a flash game? ty for reading.

  • I have a question: when you create a variable or a list, it is stored on your hard drive, correct? For how long is it stored/where is it stored? does it go away when you close python or will it stay there forever until it is deleted?

  • You could use

    >>>example[4:]

    this would give you all the numbers to the end of your list as well without using '-'

  • example[-5:10] WHy not?

  • 1:13 :|]

  • Java programmer here... PYTHON IS SUPER COOL! 6:05

  • @rednut416 Actually, you can just type example, and it'll do the same thing. Even faster

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more