Sequences: Indexing, Slicing, and Iterating | Python for Beginners Lesson 3 | Code with Kylie
Вставка
- Опубліковано 6 лют 2025
- In this beginner lesson, we learn about sequences in Python. Sequences are the foundation of more complex data structures in Python, such as lists and tuples.
Previously, we introduced the strings as a basic type. In this video, we'll revisit that and introduce it as a compound data type instead. It's a SEQUENCE of characters!
Using strings as an example, I'll demonstrate the properties of sequences in Python: indexing, slicing, and iterating! These will be applicable to other sequences (lists, tuples, etc) later on.
Timestamps:
00:00 Intro and Recap
00:50 Indexing
04:14 Slicing
07:34 Iteration
11:11 Code Demonstration
Notes: github.com/kyi...
Join the discord to learn Python with a community! / discord
I use replit.com as the code editor. If you have Python and your own editor set up on your computer feel free to use it!
Feel free to leave any questions.
Please consider subscribing if you liked this video: www.youtube.co...
Thanks for watching everyone!
~~~~~~~~~~~~~~~~~~~~~~~~
Follow me on Instagram: / kylieyying
Follow me on Twitter: / kylieyying
Check out my website: www.kylieying.com
Thanks for watching! :)
Notes: github.com/kying18/intro-to-programming/blob/main/class-2-types-mutability/notes.md
Join the discord to learn Python with a community! discord.gg/e8ZHKGU9GC
Thank you for the upload, I've just finished watching your begginer course and it is so well explained and fun. Now I am always looking forward to watching your videos.
You are great!
If she teaches Machine learning from the very beginning to advance I'll be learning it to my full even I'm not interested in ML!!!
Thanks Kylie. Well explained and good to follow along. Looking forward for the next lessons
I learned python before so here is my support for your woek❤❤❤
Thank you Kylie🙂, 14th in the series now, awesome 👍
Thank you Kylie your videos are very helpful and simple enough for me to understand as a beginner 👍
Really good content. I always not really understood the sequences in python, now I understand a lot more, thanks for the lesson.
(English is not my main language so sorry if a wrote something wrong)
could i do this with a list of scores from a test and in the for/in (like for letter in var) statement write a line to take each score fron the list, divide it by the number of questions then multiply by 100 then print the grade? is this in a later video?
figured it out! scores = [10, 3, etc] for i in scores (i/number of questions)*100 gives me a percentage grade!
Very clear explanations. Thank you 🙂
Great tutorial! Keep them coming!
You got another subscriber
Thanks for the leacture
You solve a comparative coding problem like as code code force ?
LOVE IT
When u typed for letter is letter again a new variable
it is indeed a new variable that refers to whatever iterable value that you specified. unlike some other programming languages, in Python you can use these new variables defined within the loop even outside the loop.
example:
*names = ["john", "terry", "maria"]*
*for name in names:* # for every "name" (can be any word you want, it will be = the item within your list through each iteration, recommended to use a name that makes sense) within the list "names"
*print(name)* # for every "name" (item) within the list "names" (john, terry, maria), print the item in the list
--
*output:*
john
terry
maria
--
another example to further clarify:
*greeting = "hello!"*
*for x in greeting:* # x = every iterable item (letters/characters) in "greeting"
print(x)
--
*output:*
h
e
l
l
o
!
--
and, if i wanted to use the "x" variable outside of the loop, I can:
*greeting = "hello!"*
*for x in greeting:*
print(x)
*print(x)* # notice lack of indentation means that i am OUTSIDE the for loop now! x is = "!", the final item that it iterated upon
*print(x)*
*print(x)*
--
*output:*
h
e
l
l
o
!
!
!
!
--
hope this helps!
Only useful videos out here
First.