ALL 11 LIST METHODS IN PYTHON EXPLAINED

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ม.ค. 2025

ความคิดเห็น • 85

  • @danielzima9414
    @danielzima9414 ปีที่แล้ว +5

    Sadly, this was really great. Concise, comprehensible, your voice friendly, warm and welcoming. Dig this vid a lot, might explore more.

    • @harmly2682
      @harmly2682 ปีที่แล้ว +12

      why sadly bro

    • @kingoreo7050
      @kingoreo7050 ปีที่แล้ว +4

      @@harmly2682they asked for tips at the end of the video, there are no extra tips he could add

  • @dm_5000
    @dm_5000 ปีที่แล้ว +28

    Love the channel. FYI, the key in the .sort() method doesn't have to be a lambda function. Any function will work including built-ins and functions you write yourself. Both of your examples would have worked with people.sort(key=str.lower) and people.sort(key=len)

    • @Indently
      @Indently  ปีที่แล้ว +7

      Very true, I often use lambdas in these situations to show that people can really implement their own custom functionality :)

  • @jimalix6270
    @jimalix6270 9 หลายเดือนก่อน +1

    Love your channel! Always interesting material, presented clearly and with good examples.

  • @loverboykimi
    @loverboykimi 2 ปีที่แล้ว +2

    So handy list aspects. Many thanks.

  • @hilkiahlavinier
    @hilkiahlavinier 2 ปีที่แล้ว +10

    Really love your content. Can you please do a video on time and space complexity with python examples?

    • @Indently
      @Indently  2 ปีที่แล้ว +2

      I'll look into it!

    • @BAMBAMBAMBAMBAMval
      @BAMBAMBAMBAMBAMval ปีที่แล้ว

      O(1) is 1 action
      O(log(n)) is wierd(search up "harvard cs50 phonebook" for example)
      O(n) is as many actions as iterables
      O(n²) is garbo
      Example you want to count from 0 to 10:
      O(1) = [10]
      O(log(n)) = [1, 2, 4, 8](10 wouldnt be part of the logarithm)
      O(n) = [1,2,3,4,5,6,7,8,9,10]
      O(n²) = [[1,2,3,4,5,6,7,8,9,10]1,[1,2,3,4,5,6,7,8,9,10]2,[1,2,3,4,5,6,7,8,9,10]3,[1,2,3,4,5,6,7,8,9,10]4] ect up to 10

  • @KaviyaKrish-m2w
    @KaviyaKrish-m2w หลายเดือนก่อน

    Very useful ❤

  • @kreskowkiztaksowki
    @kreskowkiztaksowki 3 หลายเดือนก่อน

    Very straight to the point video! Awesome, finally I got it lmao. I know it's simple but I guess others could not nail the explanation like you! In such hurry and simplicity I finally understood this! Thanks!

  • @TheKimphoe
    @TheKimphoe 2 ปีที่แล้ว

    Great video!

  • @muheka20
    @muheka20 ปีที่แล้ว

    thank u for tutorial. greet from Indonesia 👍

  • @-SHEESH-YIKES-
    @-SHEESH-YIKES- 8 หลายเดือนก่อน

    7:11 where i left of coding thx for the video its Awesome sauce

  • @SteveIverson-e9b
    @SteveIverson-e9b 11 หลายเดือนก่อน +2

    @8:37 sorting by people.sort(len(name)) why is 'Mario' , 'trump' , 'Luigi' the order as it is not alphabetical for length = 5? It seems to maintain original order for strings of length 5.

    • @MAlanThomasII
      @MAlanThomasII 10 หลายเดือนก่อน +3

      Correct. Python list sorting methods are stable, meaning that equal keys preserve the original order. The video was incorrect on that point.

  • @atharva7616
    @atharva7616 ปีที่แล้ว +3

    Helicopter Helicopter 😂

  • @Alextv-tz7tw
    @Alextv-tz7tw 8 หลายเดือนก่อน +1

    awesome!

  • @KRITIPANDIT-dc7yr
    @KRITIPANDIT-dc7yr ปีที่แล้ว

    I am really thankful

  • @asharsumari9313
    @asharsumari9313 2 ปีที่แล้ว

    love ur vid. thanks

  • @surajprajapati3398
    @surajprajapati3398 ปีที่แล้ว

    Very nice class I am from india

  • @Masterous
    @Masterous 2 ปีที่แล้ว +24

    what's the difference between list.clear() and list = []

    • @massy-3961
      @massy-3961 2 ปีที่แล้ว +17

      Clear is better memory wise

    • @Masterous
      @Masterous 2 ปีที่แล้ว +4

      @@massy-3961 thanks

    • @lemmenmin7676
      @lemmenmin7676 2 ปีที่แล้ว +9

      i think
      list.clear() means that list = null; // work garbage collector, clean memory
      list = [] means that list = new list(); // new pointer in memory

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 ปีที่แล้ว +1

      Actually “l.clear()” would be more equivalent to “l[:] = []”

    • @oerthling
      @oerthling 10 หลายเดือนก่อน +3

      clear empties your existing list object, while = [] creates a new empty list object.
      If you don't care about the particular object reference value, the differences are negligible in practice.

  • @KonradTamas
    @KonradTamas ปีที่แล้ว +3

    Your content and you are Great !!
    What is this notation that you use tho -------> people: list[str] = [..., ....]
    Im new to this so, this is the first place I saw it and looks clean and informative !
    Although if you add some intst there, it wont give you an error, so I dont get the [str] part,
    its just a hint to increase readability ?? Thx in advance.

    • @senge1337
      @senge1337 2 หลายเดือนก่อน

      A year late, but yes, just improves readability and LSP suggestions

  • @jaquesadv
    @jaquesadv 2 ปีที่แล้ว

    ❤❤❤❤❤❤ Thanks a lot!

  • @julyp9990
    @julyp9990 ปีที่แล้ว

    sir that was amazing teaching thank u

    • @نیگر
      @نیگر 10 หลายเดือนก่อน

      Basiji?

  • @catherinemukunga1787
    @catherinemukunga1787 ปีที่แล้ว

    wow....thank you so much....

  • @girishkrishnayadav6693
    @girishkrishnayadav6693 ปีที่แล้ว

    Very nice superb❤❤❤

  • @cerealport2726
    @cerealport2726 2 ปีที่แล้ว

    nice list!

  • @prudhvirajbandi5235
    @prudhvirajbandi5235 ปีที่แล้ว

    You super man❤

  • @realcontentgamer
    @realcontentgamer 2 ปีที่แล้ว +6

    Wait why is the filename still 'pydec' today is January which means it needs to be 'pyjan'

    • @Indently
      @Indently  2 ปีที่แล้ว +1

      It's going to get really confusing for people following the file name dates! Because that's when I created those projects ;)

    • @realcontentgamer
      @realcontentgamer 2 ปีที่แล้ว

      @@Indently oh alright

  • @eliotness4029
    @eliotness4029 4 หลายเดือนก่อน

    exellent

  • @ChitChat
    @ChitChat 3 หลายเดือนก่อน

    So I'm iterating through a list of IP addresses and a module is used to attempt to connect via SSH. Some IP addresses I know will fail and will raise a timeout error. How do I iterate to the next item in the list and continue when this happens? Also the list is created by an excel sheet.

    • @YvngStreet
      @YvngStreet 2 หลายเดือนก่อน

      Exception handling
      Wrap the code in a try block and the error in except block

  • @dky_code
    @dky_code 2 ปีที่แล้ว

    Great 👍

  • @VinothKumar-ut4rj
    @VinothKumar-ut4rj 6 หลายเดือนก่อน

    can you explain that you're assigning variable is different way

  • @faaiidodiineed6924
    @faaiidodiineed6924 2 ปีที่แล้ว +2

    Hi, I hope you are fine.
    Thank you for your helpful and well detailed videos.
    I have one request:
    Can you provide us a video that explains how to convert tkinter multiple files with mysql database into .exe file.
    Please help.

    • @Indently
      @Indently  2 ปีที่แล้ว +1

      I recommend breaking that problem down into smaller problems. It's very unlikely I will make a video so specific to that problem.

  • @JustMastermind
    @JustMastermind 2 ปีที่แล้ว

    Which editor are you using? It looks very clean.

  • @nakamuramizu..584
    @nakamuramizu..584 9 หลายเดือนก่อน

    Is extend() like concatenation

  • @kvelez
    @kvelez ปีที่แล้ว

    Great.

  • @cerealport2726
    @cerealport2726 2 ปีที่แล้ว

    Just wondering what sort of use cases there are for list.clear()?
    (I've never used it, but that doesn't mean very much!!)

    • @deei5130
      @deei5130 2 ปีที่แล้ว

      its just a little more memory efficient than list = [ ]

    • @cerealport2726
      @cerealport2726 2 ปีที่แล้ว

      @@deei5130 interesting, thanks, I might see what could do for me, I have cases where I cannot avoid lists with 4-5 million elements. Stupid proprietary data environment...

    • @TheMongole24
      @TheMongole24 2 ปีที่แล้ว +2

      I use lists in a game to create objects from an enemy class. The game runs on a loop and when the player dies, a new game is started and obviously the lists must be reset so that the new game is not already filled with enemies. I use list.clear() for that.

    • @cerealport2726
      @cerealport2726 2 ปีที่แล้ว +1

      @@TheMongole24 cool, thanks for the explanation!

  • @michellegresser7389
    @michellegresser7389 ปีที่แล้ว

    Wie kann ich Wörter nach dem letzten Buchstaben Sortieren?
    Ich habe versucht wie immer eine Key Lambda usw. Zu setzten....und am Ende ein -1 gesetzt. Aber es es geht nicht

  • @azizbekbarotboyev8015
    @azizbekbarotboyev8015 ปีที่แล้ว

    please hepl :
    print("Sartirovka")
    print()
    s=int(input())
    a=[]
    for i in range (s):
    a.append()
    a.sort()
    print(a)
    what' wrong?

    • @azizbekbarotboyev8015
      @azizbekbarotboyev8015 ปีที่แล้ว

      help*

    • @saaroopsai1063
      @saaroopsai1063 8 หลายเดือนก่อน

      a.append(argument), you are missing the argument that's to be added to the list, in your case you are not appending anython to the list.

  • @Jqts369
    @Jqts369 8 หลายเดือนก่อน

    Wait….is this supposed to be for beginners cause i have never use people: and list[str] to create a list…..how can i learn methods when i have to stop and go learn this? Idk why this is done when teaching new subjects, or diving into a beginner subject like lists

  • @tubaboytom
    @tubaboytom 15 วันที่ผ่านมา

    Elon, Trump, and Luigi.
    Wondering when we'll be introduced to Mario IRL. 💀

  • @IsaacGunananth-st7wz
    @IsaacGunananth-st7wz ปีที่แล้ว +1

    HI, why did you put "people: list[str]" wouldn't "people = [ "Mario", "Elon", "Trump" ]" do the job?

    • @Indently
      @Indently  ปีที่แล้ว +1

      Because we are adults now, and Python offers beautiful tools to simulate static type checking :)

  • @drugho92
    @drugho92 ปีที่แล้ว +1

    Helicopeeer

  • @xuzm
    @xuzm ปีที่แล้ว +1

    Can someone explain the way the code is written?
    Usually i do
    Create_list = [1,2,3,4]
    But his way is
    Create_list: list[str] = [1,2,3,4]
    Could someone explain this type of style?

  • @mtalhakhalid1679
    @mtalhakhalid1679 11 หลายเดือนก่อน

    Mostly you ise dunder in class

  • @craigslistbuslistingsofnor6494
    @craigslistbuslistingsofnor6494 ปีที่แล้ว

    you lost me at about the 10th elons

  • @lemmenmin7676
    @lemmenmin7676 2 ปีที่แล้ว

    TypeError: 'type' object is not subscriptable

    • @Indently
      @Indently  2 ปีที่แล้ว +1

      I think you meant to paste that on Google search.

    • @lemmenmin7676
      @lemmenmin7676 2 ปีที่แล้ว

      @@Indently No. This does not work on all compilers.

    • @Indently
      @Indently  2 ปีที่แล้ว

      Please explain what you mean.

    • @chaddaifouche536
      @chaddaifouche536 2 ปีที่แล้ว +2

      @@Indently He tried your code in an older version of Python and had this error because subscriptable types (like list[str]) have only been added since Python 3.9 (and you can get them with `from __future__ import annotations` if you have Python 3.7 or 3.8). He could use typing.List instead of list or just not write the annotations.

    • @callbettersaul
      @callbettersaul 2 ปีที่แล้ว +1

      @@lemmenmin7676 Python doesn't have any compilers. Python is interpreted language.

  • @pinaple7277
    @pinaple7277 หลายเดือนก่อน

    Watching this after the election. Can we just remove Elon and Trump altogether 😩

    • @Indently
      @Indently  หลายเดือนก่อน +1

      Indently videos are actually accurate prediction political videos????

  • @itsmaxim01
    @itsmaxim01 2 ปีที่แล้ว

    Array, not list.

    • @Indently
      @Indently  2 ปีที่แล้ว +3

      Please be more specific about what you're trying to explain.

    • @chaddaifouche536
      @chaddaifouche536 2 ปีที่แล้ว

      @@Indently The class *list* in Python implements what's called arrays in almost every other language and data structures books (more precisely dynamic arrays, C++ call them vectors but that's an horrible choice all of its own). If you're teaching programming with Python, it's a constant pain to every so often catch yourself referring to lists when you meant arrays just because the chosen language didn't use the standard name. Not really important in most other contexts (a rose by any other name…).

    • @callbettersaul
      @callbettersaul 2 ปีที่แล้ว

      @@chaddaifouche536 Your point being?

    • @chaddaifouche536
      @chaddaifouche536 2 ปีที่แล้ว

      @@callbettersaul I'm just explaining what maxim was referring to. All in all this video is exploring the list class in Python so I don't think this distinction is very important here but some people more accustomed to other languages do find the name irritating.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 ปีที่แล้ว

      Python has an entirely separate “array” module. And then there are NumPy arrays.

  • @vladimirtsyapka3277
    @vladimirtsyapka3277 2 ปีที่แล้ว +3

    You can get rid of the lambda function in the sort method.
    people.sort(key=len)
    It works too.