THIS Python Problem Has An Interesting Solution

preview_player
Показать описание
This Python problem has an interesting solution. #code #python #programming
Рекомендации по теме
Комментарии
Автор

almost every short is something new to me, best python content ever

headphones
Автор

I have been coding in Python for the past 6 years but had no idea such a function existed. 😅

CountryCalledCHAD
Автор

I get data with different properties in odd and even positions (b/c the instrument), so I'll have module constants:
EVEN = slice(0, None, 2)
ODD = slice(1, None, 2)
that get reused allover the place on multiple sensors. It's very readable too, so you know which data are being sent to the processor.

DrDeuteron
Автор

It's good to know you can use the function for it to reuse it.
I think the example would look better if you used different texts for the print to show you use the same slice on different objects, since i had to see the end to realize why you dont use variable (like: my_slice:str = text[::-1])

ProfRoxas
Автор

I haven't used slice before, and didn't even know it existed, but it seems obvious to me that your my_slice is going to generate a syntax error since it is meaningless.

The slice format is an interesting feature that could serve some purpose, but I don't immediately see a good use case for it.

vorpal
Автор

That's very cool i didn't even know there was a way to do that and can be very useful to slice many sequences the same way

AkivaB
Автор

If I make a programming language I am going to make a data type that is just some code. So you can save code as a variable, but not like a function. Lets say we have a function that changes a string into code like x = code("pass") now you can just type x rsther than pass, i would love this being a feature

ImpossibleEvan
Автор

What is text:str, is this variable ? In the 2nd step u didn't the variable, directly u have given slice how should it pick the above values ...could you please clarify my doubt

sravankumar
Автор

Can you please tell me the font you use in your code editor?

youarekidden
Автор

Python consistency is very... inconsistent. More and more I feel like python is a collection of one off solutions with each one only working for a limited number of use cases.

pharoah
Автор

Isn't it better to use "stringvar[a:b:c]" where a, b, c are some variables?

ahamedismail
Автор

It didn’t work because you forgot to assign the „text“ before [::-1]….

ninolindenberg
Автор

so print(text[sl_start, sl_stop, sl_step]) with sl_start=None, sl_stop=None and sl_step=-1 works and we can change any.

jyvben
Автор

Thanks so much for your valuable content ❤

ossamakamel
Автор

This is interesthing, but I think for some stuff there is usually easy alternative so they are not used so often like simple lambda in this case. I have sugestion for your video though explain several error catching like try except except when you need to handle it differently or putting errors in tuple to threat it like single error

Sinke_
Автор

Why can't you just put the string 'Python' in a variable and then the reverse slice in another variable, that works?

a = 'Python'
b = a[::-1]

print(b)

MFM
Автор

I see it a lot and am always very confused about the “text: str = ‘Python’” thing, not sure what it means and I’m wondering if someone can help. (I try to google the answer but it seems to ignore colons)

antibacterialHandwash
Автор

At this point surely there was no mistake I made when subscribing to this channel❤❤

Strong
Автор

t = "String"
print(t[::-1])
print(_[::-1])
print(_[::-1])
M - memory.

dims
Автор

Or we could have used a variable instead of "-1" magic number.
slice_idx = -1
x[::slice_idx]
y[::slice_idx]

Gameplay-psub
welcome to shbcf.ru