Python string slicing ✂️

  Рет қаралды 61,815

Bro Code

Bro Code

Күн бұрын

Python string slice tutorial example explained
#python #slice() #slicing
slicing = create a substring by extracting elements from another string
indexing[] or slice()
[start:stop:step]
name = "Bro Code"
first_name = name[:3] # [0:3]
last_name = name[4:] # [4:end]
funky_name = name[::2] # [0:end:2]
reversed_name = name[::-1] # [0:end:-1]
print(reversed_name)
website1 = "google.com"
website2 = "wikipedia.com"
slice = slice(7,-4)
print(website1[slice])
print(website2[slice])
------------------------------
Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
Free Download / Stream: bit.ly/2JnDfCE
Music promoted by Audio Library • Up In My Jam (All Of A...
------------------------------

Пікірлер: 105
@BroCodez
@BroCodez 3 жыл бұрын
# slicing = create a substring by extracting elements from another string # indexing[] or slice() # [start:stop:step] name = "Bro Code" first_name = name[:3] # [0:3] last_name = name[4:] # [4:end] funky_name = name[::2] # [0:end:2] reversed_name = name[::-1] # [0:end:-1] print(reversed_name) website1 = "google.com" website2 = "wikipedia.com" slice = slice(7,-4) print(website1[slice]) print(website2[slice])
@paticruz3992
@paticruz3992 Жыл бұрын
Bro!!! You are the fourth video I watched on the slice operator, they all failed to answered the questions I had. You sir, have answered all my questions! Subscribed. :)
@pc4n62004
@pc4n62004 Жыл бұрын
Thanks for explaining indexing and the slice function. I’m taking an online course and they really didn’t explain. The negative numbers I liked, followed, and commented. Keep them coming.
@ChristopherRichardson-se1vb
@ChristopherRichardson-se1vb 2 ай бұрын
Very concise. Python docs were confusing me on this and you really helped. Appreciate it.
@yc70jade
@yc70jade 2 жыл бұрын
Your videos are tremendously helpful. I've been tearing my hair out learning from a course today but your videos makes so much more sense. Thank you!
@FrigsyReynolds
@FrigsyReynolds 2 жыл бұрын
yeah I don't know the first thing about coding and all the videos I found assumed you knew the fundamentals. I even went so far as to start watching 'coding for kids' videos, but what this guy is doing is amazing! Breaking everything down from the very first steps, this dude is a legit bro.
@mardanpallypeddamallesh2662
@mardanpallypeddamallesh2662 Ай бұрын
Excellent lecture
@carolinesemele9066
@carolinesemele9066 2 жыл бұрын
Heavenly send. Clear explanation. I love your videos.
@_Aronix_
@_Aronix_ 3 ай бұрын
😂
@kawiurka
@kawiurka 2 жыл бұрын
I start to understand everything, thank you so so much :) You are really good in teaching and its great video (all of them).
@sajibmannan
@sajibmannan 3 жыл бұрын
Learned a lot. Thanks for the video.
@mauricelee7299
@mauricelee7299 8 ай бұрын
Thanks for walking us through this. I am just starting to learn how to code with Python and seeing you do this was really helpful. You have a new subscriber.
@he4-f2e
@he4-f2e 3 жыл бұрын
Thank you for your KZbin algorithm😌
@JasonJorgensonPhD
@JasonJorgensonPhD 2 жыл бұрын
excellent explanation of negative indexing in slicing section. A+
@famousfighter2310
@famousfighter2310 10 ай бұрын
Thanks man. Watching this right before my test
@raulviolante8675
@raulviolante8675 Күн бұрын
WOhooooooo BRO CODE
@CarbonST
@CarbonST 11 ай бұрын
Thanks dude the exclusive part was messing with me when I started with array.
@dineshgautam7027
@dineshgautam7027 2 жыл бұрын
अतिसुन्दर,,,,,,,
@samiemali6387
@samiemali6387 Жыл бұрын
thanks alot, this really helped
@EddDiaz-y7n
@EddDiaz-y7n 9 ай бұрын
Learning Python- thanks for posting-enjoyed the tutorial
@newperson4889
@newperson4889 Жыл бұрын
you make everything really simple to understand Bro thanks
@shon7022
@shon7022 3 жыл бұрын
Is there any situation where we would need to ONLY use either indexing or slicing. Or are both interchangeable?
@MADhatter_AIM
@MADhatter_AIM 6 ай бұрын
Nice
@minhquannguyen7494
@minhquannguyen7494 2 жыл бұрын
bro, something wrong with my code. When i copy slice=slice(7,-4), it returns str is not callable. How can I fix it? tk u
@Daniel-du3yf
@Daniel-du3yf Жыл бұрын
Thanks Bro
@eywwhwwhatbseg
@eywwhwwhatbseg 3 жыл бұрын
Thank you bro❤️
@tecc9-446
@tecc9-446 3 ай бұрын
nice
@EM-do1yi
@EM-do1yi 2 жыл бұрын
excellent tutorial !
@undaysmith8038
@undaysmith8038 Жыл бұрын
Awesome clip. Thanks that really helped
@dhruvivaghela8459
@dhruvivaghela8459 17 күн бұрын
u r gr8
@klemywee
@klemywee 8 ай бұрын
ez to understand. Ty!
@ma.soishob9961
@ma.soishob9961 2 жыл бұрын
Thanks,it was a helpful tutorial
@Mario-if5tl
@Mario-if5tl 10 ай бұрын
Thanks for sharing
@muhiddinergashev6202
@muhiddinergashev6202 2 жыл бұрын
Good video bro
@edisonprendi
@edisonprendi Жыл бұрын
Learnt a lot, really thanks!
@harshyadav1214
@harshyadav1214 8 ай бұрын
great video
@youtubego5109
@youtubego5109 2 жыл бұрын
thanks i learned a lot and i hope to complete it all
@mauipomare6523
@mauipomare6523 5 ай бұрын
commenting because you asked so nicely
@ubpereira
@ubpereira 2 жыл бұрын
Great vídeo bro
@ACEthetics.
@ACEthetics. Жыл бұрын
bro is nice with the code
@kemann3815
@kemann3815 2 жыл бұрын
Marvelous
@TheKing-tj4sc
@TheKing-tj4sc 10 ай бұрын
Thanks
@amokranenacer5011
@amokranenacer5011 2 жыл бұрын
exlent tuto I apreciate
@trinityjackiewicz
@trinityjackiewicz 10 ай бұрын
Hey, thank you!! :)
@xlpianomover2871
@xlpianomover2871 Жыл бұрын
thank you! super helpful!
@imranb5088
@imranb5088 2 жыл бұрын
thank you for the lessons!
@charlescarlbilly4234
@charlescarlbilly4234 8 ай бұрын
thanks bro
@SavingTheCows
@SavingTheCows 3 жыл бұрын
Thank you!
@xXxUNxXxJ00017
@xXxUNxXxJ00017 11 ай бұрын
Thx!
@yiorgoskatopodis
@yiorgoskatopodis 2 жыл бұрын
Excellent!
@beingzero7541
@beingzero7541 2 жыл бұрын
INFORMATIVE!
@NotSpecAlt
@NotSpecAlt 2 ай бұрын
thnx bro!
@spartanranger
@spartanranger 3 жыл бұрын
Thanks for the video
@ГОЛОСНИК-б5б
@ГОЛОСНИК-б5б 2 жыл бұрын
It is great !
@jean-paulmpindumukandila1251
@jean-paulmpindumukandila1251 2 жыл бұрын
Hello I have a question with the slice function index -4 is exclusive or inclusive. Thanks
@lionbreeda2776
@lionbreeda2776 2 жыл бұрын
[1:-4] its exclusive, [-4:-2] inclusive
@thorcoder1
@thorcoder1 3 жыл бұрын
You are great 👍👍😽👍🙏🙏
@SolidusPL
@SolidusPL 2 жыл бұрын
The entire lesson is clear and easy to understand. But I have a small question, is it possible that the index function could be set to a character such as a space or a comma and not to a letter position in a line. For example, I am doing input, please enter the first name and last name, so that index is to the first name to a space and index to the second name from a space.
@hariprashaadsr7463
@hariprashaadsr7463 Жыл бұрын
You can use find( )... name = input("Enter ur name : ") hi = name.find(" ") slice = slice(0, hi) if hi == -1 : print (f" Your first name is {name.capitalize} ") else: print (f" Your first name is {name[slice].capitalize()}") 😄
@hasanteke07
@hasanteke07 2 жыл бұрын
start stop step ahh u are nice thanks
@Little_smuff_r
@Little_smuff_r 10 ай бұрын
master
@ghoggaliabdou4222
@ghoggaliabdou4222 3 жыл бұрын
Thank you bocd 💙💙
@不重要-c2r
@不重要-c2r 4 ай бұрын
Hey Bro, I use the Google colab to program. When I'm trying to use slice function, the system told me that "'slice' object is not callable" I'm wondering why?
@passportbro904
@passportbro904 4 ай бұрын
shout out to people that just press the like button for bros videos, just because
@budderrar5751
@budderrar5751 2 жыл бұрын
noice
@oku1234
@oku1234 3 жыл бұрын
thank you
@tylerholland4652
@tylerholland4652 4 ай бұрын
Why is it that when I write my code exactly as he does I get an error saying that 'sllice' object is not callable. In order to see it was not my fault, a copy and pasted the code exactly from the description and still got an error. I was using Google colab when I got this error but I did not get this error when I downloaded pycharm and wrote the code in there. Why?
@kubach2897
@kubach2897 3 жыл бұрын
Tks bro
@tedchiu1433
@tedchiu1433 3 жыл бұрын
thanks
@verojoe1988
@verojoe1988 Жыл бұрын
Can you make a tutorial on pygame plzzz sir
@marshallyose8887
@marshallyose8887 2 жыл бұрын
Thanks edoC orB
@BAMBAMBAMBAMBAMval
@BAMBAMBAMBAMBAMval Жыл бұрын
eDoc with the orb
@ozba
@ozba 3 жыл бұрын
perfect
@user-up6jq6qn8j
@user-up6jq6qn8j 3 жыл бұрын
is your name really bro code?
@pippo9543
@pippo9543 3 жыл бұрын
bruh you really asking?
@jordanbuckle9146
@jordanbuckle9146 2 жыл бұрын
Try Ty
@tarikyassa1076
@tarikyassa1076 3 жыл бұрын
👍
@Melvishify
@Melvishify 3 жыл бұрын
Ey bro.. thanks
@alexyakoveno4682
@alexyakoveno4682 Жыл бұрын
@user-sh5zv4yf5s
@user-sh5zv4yf5s 3 жыл бұрын
Were did you learn python
@neeraj4210
@neeraj4210 3 жыл бұрын
❤️
@hostvind
@hostvind 2 жыл бұрын
now PyCharm is no more tolerant to variables' names same as the function's. So rename that "slice" var into... say, "slicee"
@darrenlouisuyangurin
@darrenlouisuyangurin Жыл бұрын
i didnt understand the output of funky_name = name[::2]. can someone explain to me pls, i understand that the default is 1 but i dont get the 2 and 3
@ilyaakradi3560
@ilyaakradi3560 Жыл бұрын
Basically, the number that you put after the second colon (the step) is how many indexes of the string the compiler will increment(or decrement by, if the value is negative) when slicing the string. In the case of funky_name, since the step value is 2, every other letter in the name is printed because the index will be going up by 2 instead of the default 1. Hope this helps.
@DarkAcademyUniversity
@DarkAcademyUniversity 8 ай бұрын
@nyatibros2172
@nyatibros2172 Ай бұрын
Broooo
@sheelareddy7969
@sheelareddy7969 3 жыл бұрын
bro can you create josh clone
@realarchie9043
@realarchie9043 3 жыл бұрын
Why am I getting invalid syntax
@hostvind
@hostvind 2 жыл бұрын
It wasn't a good idea to use the name for the variable "slice" same as the function's "slice ()"
@kurtmann7595
@kurtmann7595 2 жыл бұрын
youtube algorithm comment
@tintingchen6558
@tintingchen6558 3 жыл бұрын
Hey bro this video no Chinese cc >
@mincart9899
@mincart9899 3 жыл бұрын
I think bro code eated alot of brocoli s
@Times343
@Times343 11 ай бұрын
Bro
@aaagames561
@aaagames561 5 ай бұрын
t u
@SuperMarioBros843
@SuperMarioBros843 Жыл бұрын
hell💀
@clickherenow9946
@clickherenow9946 2 жыл бұрын
Great Video
@ihatewomen9183
@ihatewomen9183 2 жыл бұрын
cool
@maryal7502
@maryal7502 Жыл бұрын
Thanks
@davelaff73
@davelaff73 3 жыл бұрын
Nice
@airlanggak5391
@airlanggak5391 3 жыл бұрын
thanks!
@asteiaellinikitv4193
@asteiaellinikitv4193 2 жыл бұрын
@headlesshair1353
@headlesshair1353 2 жыл бұрын
Thanks
@AnishSaha_
@AnishSaha_ 3 жыл бұрын
Thanks
@gokulc7043
@gokulc7043 3 жыл бұрын
Thanks bro
ALL 47 STRING METHODS IN PYTHON EXPLAINED
23:34
Indently
Рет қаралды 132 М.
Python string format 💬
12:47
Bro Code
Рет қаралды 31 М.
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
Do you choose Inside Out 2 or The Amazing World of Gumball? 🤔
00:19
МАИНКРАФТ В РЕАЛЬНОЙ ЖИЗНИ!🌍 @Mikecrab
00:31
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 42 МЛН
Python Decorators in 15 Minutes
15:14
Kite
Рет қаралды 443 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 161 М.
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 147 М.
Functions in Python are easy 📞
10:38
Bro Code
Рет қаралды 485 М.
Python dictionary comprehension 🕮
8:41
Bro Code
Рет қаралды 37 М.
Python lists, sets, and tuples explained 🍍
15:06
Bro Code
Рет қаралды 275 М.
Lecture 1: Introduction to CS and Programming Using Python
1:03:30
MIT OpenCourseWare
Рет қаралды 709 М.
Python inheritance 👪
7:19
Bro Code
Рет қаралды 81 М.
Learn Python With This ONE Project!
55:04
Tech With Tim
Рет қаралды 1,8 МЛН