2D Lists & Nested Loops - Python - Tutorial 24

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • Source Code - www.giraffeacad... This video is one in a series of videos where we'll be looking at programming in python. The course is designed for new programmers, and will introduce common programming topics using the python language.
    Throughout the course we'll be looking at various topics including variables, lists, tuples, loops, conditionals, object orientation, and much more.

КОМЕНТАРІ • 90

  • @seth6072
    @seth6072 4 роки тому +104

    This is so simple. I wish my class actually taught me this instead of just expecting me to know it. Thanks dude!

    • @friktogurg9242
      @friktogurg9242 2 роки тому

      Is there a way you can continuously append into the 2d array? something like in a while loop?

  • @theycallmeerikaalexa1037
    @theycallmeerikaalexa1037 6 років тому +49

    Dude, this is so good. Ive been fighting with 2D arrays in python for 2 days now and then realized python treats it more like a list. Im so happy to have found this video.

  • @lansdonalcorn6998
    @lansdonalcorn6998 3 роки тому +1

    This video really helped me understand 2D arrays. I was struggling prior to watching this lol

  • @generik6224
    @generik6224 4 роки тому +1

    Thank you sooooooooooo much. I've been looking for videos like this for ages

  • @collin3012
    @collin3012 5 років тому +7

    Damn this was useful haha thanks for helping with my classes dude.

  • @jeekakrishna
    @jeekakrishna 2 роки тому

    Just what i needed

  • @kurdobakur7047
    @kurdobakur7047 5 років тому +5

    How can return unnestted elements(individual [1d]lists) from that 2d list in a function?

  • @nikhilnayak2179
    @nikhilnayak2179 4 роки тому +1

    this is good but how to access if a list contains [1,2,3,[3,5,6,[6,5,7],6,8,0],9,1,5] ??

  • @Exoticelaf
    @Exoticelaf 5 років тому +4

    This guy is amazing! yall should check out his other py vids! very helpful!

  • @chingzhu2149
    @chingzhu2149 5 років тому +4

    Mike,thank you so much for the excellent job! It is very useful for me to understand two dimensional lists in Python.

  • @AM-zn7dk
    @AM-zn7dk 5 років тому +1

    Why is your Python different from mine e.g. mine is white and dosent have numbered lines is it just because i use idle Python ?

  • @tiffanybedal2985
    @tiffanybedal2985 5 років тому +9

    Love learning from you!!! You do a great job breaking things down and delivering them in simple language. Thank YOU!

  • @lebronjames3623
    @lebronjames3623 4 роки тому +2

    Dang you deserve a million subs for doing this

  • @Dopeboyz789
    @Dopeboyz789 5 років тому +1

    Can you match or compare two nested list with the same value or element

  • @oajugade8917
    @oajugade8917 3 роки тому +1

    Hi, how to append two matrices side by side in python? Please anyone, I require it urgently.. Thanks

  • @RussellSchaare
    @RussellSchaare 3 роки тому +2

    Mike, you're a legend. Simple explanations, easy to understand and apply. This same stuff took me over twice as long to learn at university!

  • @kvnagendra5354
    @kvnagendra5354 5 років тому +2

    arr = [1, 2, [3, 4], 'a', 'b']
    print arr[4: 0: -2]
    Ans) ['b', [3, 4]]
    Anyone can explain what the heck is this

    • @Chaos_x5
      @Chaos_x5 5 років тому +2

      It goes from position 4 to pos 0 in steps of negative 2
      If you try print(arr[3:0:-1])
      You get a,[3,4],2
      Print[1:4:2]
      Gives 2,a
      Try some other combinaitions if you still don't understand

  • @kpieceemmry3387
    @kpieceemmry3387 Рік тому

    So does it mean that row & col are attributes in Python or if I replace them with another word, it will still work normal? Don’t know if there are more method or class options for this. Thanks 🙏 again

  • @dakshbhatnagar
    @dakshbhatnagar 2 роки тому

    Hey Man, I have got some ML models and bunch of model evaluation metric. I want to use a nested for loop so that it gives me the each metric for each model. How can I go about it??

  • @franfranfran3611
    @franfranfran3611 5 років тому +1

    How can you work with the indices of each sublist and put it in a for loop. For example, in your array, say we want to multiply first the first indices so it would be 1*4*7*0 and then it would work with just the second indices and so forth...and how would you do a general code for something like that?

  • @yaswanthvejendla8010
    @yaswanthvejendla8010 Рік тому

    hey dude! i think there is mistake in code provided below the video in website
    i.e instead of for col in row: you put for row in col:

  • @Waspinator86
    @Waspinator86 4 роки тому

    hi, I need help . . I have a 20000*3 matrices and I want to concatenate all elements of each column by step 100 in another matrices which is 200*3 . . .

  • @secretdofus5830
    @secretdofus5830 2 роки тому

    Ty ty ty ty ty ty
    I watched alllllllll the ad cause you deserve the last cent for this epic and useful video u made

  • @alexandermrkich8734
    @alexandermrkich8734 4 роки тому

    Thank you. Very helpful.

  • @yasirjune69
    @yasirjune69 5 років тому +1

    Thanks bud.

  • @LuminosityZero
    @LuminosityZero Місяць тому

    "miked"
    hmm
    seems slightly familiar

  • @TheInsanity.
    @TheInsanity. 2 роки тому +1

    Mike is so good at teaching

  • @diogeneslantern18
    @diogeneslantern18 3 роки тому

    With respect, nothing was explained for nested for loops (ie from 3:30 onwards). My understanding is that you used "row" as a simple variable name (and could have used "across" or "happy" or whatever), but why does it print the numbers verbatim, ie
    [1, 2, 3]
    [4, 5, 6]
    [7, 8, 9]
    [0]
    in the "row" loop;
    Whereas the numbers are printed as
    1
    2
    3
    4
    5
    6
    7
    8
    9
    0
    in the column loop?
    You completely gloss over the why behind how.

  • @unfinishedbluesrandom1081
    @unfinishedbluesrandom1081 5 років тому +2

    THANK YOU I LOVE U

  • @ingridgarcia-solera6236
    @ingridgarcia-solera6236 5 років тому +3

    How do I access to only certain values inside of my nested loop. for.ex: values = or >100
    Thanks!

    • @TheSlytooth
      @TheSlytooth 5 років тому

      did you end up finding out?

    • @Gwyn94
      @Gwyn94 5 років тому +2

      I believe you'd need to add an if statement inside the nested loop. For example:
      for row in number_grid:
      for col in row:
      if col

  • @anitasunildesai
    @anitasunildesai Рік тому

    how to create a nested list with from single list?

  • @koorieph2697
    @koorieph2697 2 роки тому

    How do i change 1 element of the 2d list?

  • @abbykoch9940
    @abbykoch9940 6 років тому +1

    This is awesome, thank you :)

  • @angelcarlson7712
    @angelcarlson7712 4 роки тому

    Can someone please help me? For the life of me I cannot understand anything past 3:27 when he talks about nested for loops. I tried to mess around with the program to see if I understood it in different scenarios, but honestly I got lost when I typed:
    number_grid = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [0]
    ]
    for row in number_grid:
    for col in row:
    print(row)
    and got the following output:
    [1, 2, 3]
    [1, 2, 3]
    [1, 2, 3]
    [4, 5, 6]
    [4, 5, 6]
    [4, 5, 6]
    [7, 8, 9]
    [7, 8, 9]
    [7, 8, 9]
    [0]
    I just can't wrap my head around this or explain what happened to get this result. Can someone please walk me through this specific example?

  • @samriddhijain1651
    @samriddhijain1651 6 років тому +7

    Hey in the code section of this video on your website, you have written
    for row in col:
    instead of
    for col in row:

    • @СвітланаДукач
      @СвітланаДукач 4 роки тому +1

      I have just wanted to write the same)). I think, Mike did this mistake intentionally to make students think))

  • @Respectemall
    @Respectemall Рік тому

    bro thats okay but how to add list in a nested list

  • @noahgoodin2159
    @noahgoodin2159 4 роки тому +1

    when i try to practice this code on pycharm it says TypeError: list indices must be integers or slices, not tuple. Anyone know why or of its fixable

    • @togbot3984
      @togbot3984 4 роки тому

      What brackets you used

    • @karinah6762
      @karinah6762 4 роки тому

      maybe you forgot comma between the lists?

  • @rm9994
    @rm9994 3 роки тому

    Could the words row and col be anything. I mean it’s not a known command in python, it’s a word you choose? Like you can call a variable anything, it still works just as well.

  • @moniquebrasilbaptista1989
    @moniquebrasilbaptista1989 Рік тому

    Very helpful. Thank you!

  • @adityadwivedi8798
    @adityadwivedi8798 4 роки тому

    A GREAT DOUBT! --- when you typed only one for loop and printed (row). In output we got all the numbers including square brackets [ ] but why after second loop everything got so clear? I mean where are those brackets? ....
    I literally didn't got the logic.. Can anyone explain me?

  • @JemQuadri
    @JemQuadri 4 роки тому

    Hello, I got a little problem with 2D arrays and I’m supposed to write a function that accepts 2D arrays as a parameter and I have no idea how to do it
    I tried :
    Import numpy as np
    def getrws([[],[]]): but it keeps showing errors

  • @loganhawkins6486
    @loganhawkins6486 4 роки тому

    if you had a list of numbers how could you group every set of 4 numbers together? so if you had 12 numbers you would have 3 lists of 4.

  • @zvonkocosic5939
    @zvonkocosic5939 4 роки тому

    How do you delete the list from 2d list?
    If some list is empty, and you want to delete an items from the second list, how do you do that?
    Thank you!

  • @eribertoiiibeduya2024
    @eribertoiiibeduya2024 4 роки тому

    how do you make a list of fruits and drinks in separate string variable and make a mix list print output where it shows all the possible mix drinks you can have from the fruit and drinks variables?

  • @irhcsa
    @irhcsa 5 років тому +1

    Very helpful. Thank you.

  • @Samuelkings
    @Samuelkings Рік тому

    I swear we learn things easier on UA-cam than in school. Cancel colleges lol

  • @kartikbhatia300
    @kartikbhatia300 2 роки тому

    if you can clear my doubt then it would be a great help
    what if the list is not user defined?

  • @ajaymundhe795
    @ajaymundhe795 4 роки тому +1

    this is so simple

  • @biirdman89
    @biirdman89 4 роки тому

    Holy crap I used to thi k Mike and TechWithTim were the same guy

  • @satyanarayanasimma6945
    @satyanarayanasimma6945 4 роки тому

    Sir if possible can do a video for how to do arithmetic operations on all elements in a list at same time not by using index values is it possible sir

  • @Abkklp
    @Abkklp 2 роки тому

    Your videos are really great, I have one question like how can access individual rows

  • @tareqalalwan
    @tareqalalwan 5 років тому +1

    You rock! Mike!

  • @rheajoyce868
    @rheajoyce868 4 роки тому

    you might want to do Frequency distribution table😊😊using python.

  • @thurrie
    @thurrie 4 роки тому

    How do you add the numbers in the column and output it separately?

  • @abdullatefalfares7258
    @abdullatefalfares7258 4 роки тому

    thank you , very helpful , but how about if the list was string

  • @suneosama939
    @suneosama939 10 місяців тому

    Bro you so fucking good

  • @JT-nh5fu
    @JT-nh5fu Рік тому +1

  • @HiruniAbeysekara-fl1ij
    @HiruniAbeysekara-fl1ij 24 дні тому

    thank you sir😍😍😍

  • @krystal2131
    @krystal2131 3 роки тому

    Oh my gooodness, I can't believe it's that simple. Thank you!

  • @TaSSAdunAiur
    @TaSSAdunAiur 4 роки тому

    Your are f...ing AWESOME ! You explain for dummies like me to understand. Thanks man ! You got a +1 Subscriber :)

  • @codingxllama
    @codingxllama 6 років тому +1

    How can you make a 2d array from taking user input ?

    • @paulaxa1
      @paulaxa1 5 років тому

      ua-cam.com/video/dsLpJxu3ihI/v-deo.html

  • @sarabintereza2022
    @sarabintereza2022 3 роки тому

    THANK YOU SO MUCH

  • @aris_mggr6140
    @aris_mggr6140 2 роки тому

    MAN I FUCKIN LOVE YOU THANKSS

  • @vinayakmishra8408
    @vinayakmishra8408 2 роки тому

    bro smile too...

  • @toushiroy5952
    @toushiroy5952 3 роки тому

    thanx for this

  • @patrickwolf4623
    @patrickwolf4623 4 роки тому

    how do i access the last item in each list and print?

  • @maryxue5532
    @maryxue5532 7 місяців тому

    Thank You!

  • @thomash7247
    @thomash7247 2 роки тому

    Thanks !

  • @hanatekletekle7121
    @hanatekletekle7121 3 роки тому

    God Bless

  • @superbo9y36
    @superbo9y36 3 роки тому

    can you name each list within a list?

  • @lvan5
    @lvan5 2 роки тому

    Straight legend! such an easy and great explanation, thank you!

  • @rbrtsparkman
    @rbrtsparkman 4 роки тому

    how to loop values into a multi-dimensional list?

  • @BhojrajoO
    @BhojrajoO 2 роки тому

    🙏

  • @paulasemedo5170
    @paulasemedo5170 6 років тому +5

    Do you work at nasa?

  • @aryavaraste1949
    @aryavaraste1949 4 роки тому

    Thanks Mike you are making great things

  • @kurtroberts9531
    @kurtroberts9531 3 роки тому

    thank you for this!

  • @bhangrafan4480
    @bhangrafan4480 2 роки тому

    Excellent, clear, concise and to the point!

  • @HIDlarissaTERRY
    @HIDlarissaTERRY 4 роки тому

    Thank you!

  • @ranhny2022
    @ranhny2022 4 роки тому

    i want that shirt

  • @yonatan1myers
    @yonatan1myers 4 роки тому

    nice but... This is the simple stuff. How would you init an n-dimensional "array: all to 0?