I JUST Found Out About This Python Trick! #python #coding #programming

preview_player
Показать описание
How to use a step argument with a slice operation in Python!
Рекомендации по теме
Комментарии
Автор

i knew this i told my lecturer this once and he was impressed lol

lightless
Автор

Python: [start:end:stepsize]
Matlab: (start:stepsize:end)
My will to live: gone

theninja
Автор

[<starting index>:<ending index>:<step>]

GRBSnatch
Автор

This reminds me "range" function. Because the first number you'll write means at what point you will start from your list and the second one is where to end. The third one is how to count, like if you insert "1" it will go by every first item in the range, if you put "3" it will go through every third one, enc. It's really cool that you can do the same stuff but easier

NONAME-hqqo
Автор

So many tricks to achieve similar goals could be problematic.

wisataakhirpekan
Автор

Anyone trying to remember, slices work as [start:end:stride]

calcultor
Автор

You can write print (a[::-1]) no need the b

edbertkhovey
Автор

I just learned this this morning on sololearn lol.

Gurkems
Автор

welcome to slicing of lists and tuples.

beepbeepgamer
Автор

I stumbled on your acc few days back and honestly love it. Please keep making content.

eepnes
Автор

You just discovered this???!!! 😮😮😮WOW, congrats, man!

willsee
Автор

thats basically why i picked python over c++ or java on my highschool ict exam, you can actually check eg. if input is palyndrome using [::-1] instead of writing whole function and wasting time on c/java syntax!

krzysiekstawarz
Автор

b[-1::-2] is same as b[::-2]
b[-2::-2] gives every other backwards starting with 9 instead of 10

marklandgraf
Автор

Have known this for a while. It comes in handy when working with endianness.

TheDutchisGaming
Автор

ITS LITERALLY IN THE DOCUMENTATIONS, EVEN I KNOW THIS AND I'VE BEEN DOING PYTHON FOR LESS THAN A DAY!?

IllusionEDM
Автор

Bruh thanks alot!! I was fugging trying to figure out how to print every item from a list

Exotic
Автор

Meanwhile me coding a full program to reverse a list in c 😐

danielhod
Автор

How do you setup your IDE to look like this?

TheDevilsHand
Автор

what is your keyboard sound if thats your actual keyboard what is the build if not then where u get that sound plz i need it

Benmenesesjr
Автор

Bro i believe this was in the manual itself

heinrichskies
join shbcf.ru