From the course: Python for JavaScript Developers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Python slices - Python Tutorial
From the course: Python for JavaScript Developers
Python slices
- [Instructor] Slices allow us to quickly manipulate strings and collections. Gaining familiarity with them may save us quite a bit of time. Moreover, it keeps our code more clean and concise. So here I am in 02_05.js just to have a starting point and look at a JavaScript slice. So on line one, I define an array of three ages, basically three numbers. And on line three, I grab those last two numbers, using the slice method. Then on line four, I console.log this. So let's just run this code. So here I am in my terminal and I'm going to run this using node since this is JavaScript. CH_02_05.js. And I get the last two items. So let's clear my terminal. So let's have a look at some Python slices. So here I am at 02_05.py and functionality of slicing is very similar in Python. Syntax, however, is a bit different. So here on line one, I define a list of four items called AGES and on line two, I just grab the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Why style is crucial5m 44s
-
(Locked)
Numbers, numeric types, and decimals4m 58s
-
(Locked)
Migrating from arrays to Python lists, tuples, and dictionaries8m 20s
-
(Locked)
Strings and formatting: Python vs. JavaScript3m 38s
-
(Locked)
Python slices4m 11s
-
(Locked)
Challenge: Port the code1m 17s
-
(Locked)
Solution: Port the code1m 43s
-
-
-
-
-