Python Tutorial: Slicing Lists and Strings

Python Tutorial: Slicing Lists and Strings

Corey Schafer

8 лет назад

431,413 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@user-mc9fm9hz2t
@user-mc9fm9hz2t - 30.11.2023 17:34

please tomorrow i will have a test abt this. please bless me

Ответить
@ahogretarefalto
@ahogretarefalto - 18.11.2023 18:23

In wich flowchart symbol sould i write the index ??

Ответить
@callumwrtaggart7527
@callumwrtaggart7527 - 25.10.2023 20:55

Can i slice a float number like 1.23456 and extract the number 3

Ответить
@user-uz1st2cm7q
@user-uz1st2cm7q - 10.09.2023 17:28

Thanks bro

Ответить
@prithishas970
@prithishas970 - 09.08.2023 10:34

You are not using parenthesis () for print then how did the output came?

Ответить
@abdulmusawir4342
@abdulmusawir4342 - 30.07.2023 08:29

awesome

Ответить
@airmett8939
@airmett8939 - 27.06.2023 22:25

Program to flip what the user writes and remove all the vowels.

new=[]
flapjack=input("Write a sentence: ")
for i in range(len(flapjack)):
if flapjack[i]!="a" and flapjack[i]!="e" and flapjack[i]!="i" and flapjack[i]!="o" and flapjack[i]!="u" and flapjack[i]!="A" and flapjack[i]!="E" and flapjack[i]!="I" and flapjack[i]!="O" and flapjack[i]!="U":
new.append(flapjack[i])
newer=(new[len(new):-len(new)-1:-1])
print("".join(newer))

I suppose it could be turned into a game by then user 2 guessing the original sentence.

new=[]
flapjack=input("Write a sentence: ")
for i in range(len(flapjack)):
if flapjack[i]!="a" and flapjack[i]!="e" and flapjack[i]!="i" and flapjack[i]!="o" and flapjack[i]!="u" and flapjack[i]!="A" and flapjack[i]!="E" and flapjack[i]!="I" and flapjack[i]!="O" and flapjack[i]!="U":
new.append(flapjack[i])
newer=(new[len(new):-len(new)-1:-1])
print("".join(newer))
guess= input("Guess the original sentence: ")

if guess==flapjack:
print("You win!")
else:
print("No bueno")

Ответить
@mahnoorfatima3553
@mahnoorfatima3553 - 26.06.2023 10:30

Which application youbare using for practice in this vedeo

Ответить
@tonysolis6364
@tonysolis6364 - 10.05.2023 03:29

how do i print the frist and last element only?

Ответить
@timothymaggenti717
@timothymaggenti717 - 20.03.2023 00:38

Your videos are well worth the time; thanks so much. Very well done

Ответить
@immujaan2005
@immujaan2005 - 14.02.2023 15:42

Thank you that was helpFull.....

Ответить
@bluetortilla
@bluetortilla - 08.02.2023 05:49

Corey is the clearest and most concise Python teacher around. You're the best, Corey!

Ответить
@commanderchiefmaster
@commanderchiefmaster - 04.02.2023 19:49

Thank you for this concise and easy explanation

Ответить
@emmanuelchukwuemeka6264
@emmanuelchukwuemeka6264 - 21.01.2023 16:12

how do you use the print function without the bracket and you get away with it 🤔

Ответить
@Suryababu-cd4zu
@Suryababu-cd4zu - 20.01.2023 15:22

Is it work on tuples

Ответить
@saimanideep857
@saimanideep857 - 17.01.2023 07:03

I have a doubt. If you run str_name[::-1] you get the string in reveresed format. But when i try str_name[0:4:-1] note that the length of string is 4, so I'm directly giving the start as 0 and end as the total string, and the index is -1. When I run this, it doesn't work! Why? Can anyone say please?

Ответить
@youssefbenkadria2297
@youssefbenkadria2297 - 11.01.2023 03:00

Hey how can i find a ch[i] in a tableau of ch

Ответить
@bhupendranagar3434
@bhupendranagar3434 - 19.12.2022 14:16

thank you

Ответить
@shreyaschavhan5522
@shreyaschavhan5522 - 14.12.2022 07:40

+ Syntax: list[start:end:step]

Ответить
@flowTwin
@flowTwin - 24.11.2022 01:46

Thanks bro, after 4 hours i can fix the problem so easy, after i see you in 10 minuts 🤣i folow you bro

Ответить
@kareemali8778
@kareemali8778 - 06.11.2022 18:46

been taking a course at a university for the last 2 months and we are focusing entirely on python. This guy explains everything so well to the bone my mind is blown and my skills are getting better. thanks for your incredible content!

Ответить
@rahelina7176
@rahelina7176 - 25.10.2022 20:49

your videos are such gems :))

Ответить
@Sasho14
@Sasho14 - 17.09.2022 14:14

Very well explained! Thank you so much!

Ответить
@matthewmakowski6463
@matthewmakowski6463 - 16.09.2022 18:22

Wow, you covered what I've been confused for 3 days on within two minutes. For some reason, it wasn't explained to me that it was start:end:STEP. I was so confused what double colon meant(::) and i couldn't get my solutions. Also confusing was they called the first value of the slice an INDEX value and the second part the ELEMENT value. I think it's just much easier for learners to just understand the endpoint is THROUGH until endpoint, like a stop. That saved me a lot. thanks a ton!

Ответить
@nidae1076
@nidae1076 - 03.09.2022 16:19

Thank's a looot

Ответить
@siddharthanandi
@siddharthanandi - 01.09.2022 14:43

aswm explanation man god bless you make more video keep providing knowledge us ❤

Ответить
@GodLy2210
@GodLy2210 - 26.08.2022 17:58

hey i have a doubt..if this is the case how to print the only first element and the last element in a list?? take an exmpl frm the video itself from my_list, so now how do you only print the 0 and 9 from the list???

Ответить
@samikshyanmishra7454
@samikshyanmishra7454 - 30.07.2022 10:12

If perspicuous had a face then that's you!

Ответить
@muralidhar40
@muralidhar40 - 26.07.2022 09:33

why didn't the slice [2:-1:-1] work

Ответить
@mstanleydo
@mstanleydo - 20.07.2022 18:15

In a different video Corey said that there is a good reason why the first element is included and the last element is non-included during these operations. What is that reason?

Ответить
@oguzturkyilmaz543
@oguzturkyilmaz543 - 05.07.2022 14:22

Many thanks

Ответить
@tremaine6567
@tremaine6567 - 22.06.2022 03:01

This is well explained bro.. thank you so much

Ответить
@shreyashkashyap
@shreyashkashyap - 08.06.2022 21:31

You really helped me a lot man, thank you very much!

Ответить
@rajendrakubde3688
@rajendrakubde3688 - 01.06.2022 15:09

Heyy corey ...u explain simple very well .i found it well intresting .god bless you .keep uploading

Ответить
@frederic_viennot
@frederic_viennot - 21.05.2022 17:39

super concise and clear !!!! amazing !!! thank you;))

Ответить
@bs5am
@bs5am - 11.05.2022 10:46

If Corey was Swedish I’d try to hire him as my personal python teacher.

Ответить
@DiegoMalo88
@DiegoMalo88 - 10.05.2022 17:59

thanks for this

Ответить
@user-qn5by5iv7u
@user-qn5by5iv7u - 02.05.2022 11:32

2022

Ответить
@smollstag5312
@smollstag5312 - 28.04.2022 09:15

thank you for this list slicing tutorial! very simple and easy to follow, completely explained what i was struggling with. thanks a lot!

Ответить
@lyujunxiu5407
@lyujunxiu5407 - 24.04.2022 08:12

your explanation is quite clear. And with standard spoken English, I even no need to turn on the subtitle. Thanks a lot.

Ответить
@GK-jw8bn
@GK-jw8bn - 21.04.2022 13:29

best python series ever!

Ответить
@himanshumaithani5681
@himanshumaithani5681 - 17.04.2022 21:21

Thanks for the video, was always confused with the negative indexing

Ответить
@ra1785
@ra1785 - 07.04.2022 17:13

Thank you for such a well-explained tutorial! This really helped me!

Ответить
@Imran20091990
@Imran20091990 - 15.03.2022 10:49

Corey while making video.. could you pls change the theme. it's very difficult to see the content.. however your video is awesome with clear explanation and details.

Ответить
@kadenyoung2214
@kadenyoung2214 - 15.03.2022 10:27

How would you take a string, and make it so it repeats the string in Upper,Lower,*

Ответить
@abishek20104
@abishek20104 - 06.03.2022 06:23

Thanks very much... That's very informative and useful.✌🏼🙌🏼

Ответить
@muniswamykarri101
@muniswamykarri101 - 05.03.2022 22:59

The print function doesn't work for me without parentheses.
print my_list[0:5]... doesn't work.
print (my_ist[0:5]) is only working.

Ответить