Accessing Elements of a List in Python

Поділитися
Вставка
  • Опубліковано 24 сер 2024

КОМЕНТАРІ • 142

  • @hariprashant5873
    @hariprashant5873 7 місяців тому +55

    my_list = [[1, 2, 3], [['a', 'b', 'c'], 5, 6]]
    print(my_list[1][0][1])

  • @MrUnknown-z5w
    @MrUnknown-z5w 11 місяців тому +22

    print(my_list3[1][0][1])
    Output:- b

  • @jingersatuh6322
    @jingersatuh6322 6 місяців тому +3

    This is a very difficult topic. The presentation was so good that I understood it so easily.

  • @ahmeduddin222
    @ahmeduddin222 8 місяців тому +4

    great, i was having issue in understanding Lists. You explained it very well. Thanks

  • @jereddymanojkumar3830
    @jereddymanojkumar3830 Рік тому +15

    My_list3[1][0][1]='b'

    • @lionelfaith3646
      @lionelfaith3646 10 місяців тому +2

      syntax error My_list3 is undefined, in python My_list3 != my_list3

    • @DANISH-MAHI
      @DANISH-MAHI 6 місяців тому

      😂😂lol@@lionelfaith3646 , good observation

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

      ​@@lionelfaith3646bro

    • @Grass_Hopper7
      @Grass_Hopper7 3 дні тому

      👍👍​@@lionelfaith3646

  • @jeremyserbee3720
    @jeremyserbee3720 3 місяці тому

    these videos rock. thank you !

  • @RahulSingh-qs9ed
    @RahulSingh-qs9ed 5 місяців тому +1

    li1 = [[1,2,3],[['a','b','c'],[5,6]]]
    print(li1[1][0][1])

  • @yadavstuntboy..6490
    @yadavstuntboy..6490 4 місяці тому

    16:40 my_list3 = [[1, 2, 3], [['a', 'b', 'c'], 5, 6]]
    for accessing 'b' item from my_list3
    print(my_list3[1][0][1])

  • @TheDataMagic_x
    @TheDataMagic_x 2 місяці тому

    l1=[[1,2,3],['A','B','C'],5,6]
    print(l1[1][1])
    we can use this type

  • @arghadutta89
    @arghadutta89 8 днів тому

    my_list3=[[1,2,3],[['a','b','c'],5,6]]
    print(my_list3[1][0][1])

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

    Print(list_1[1][1])
    Out of range if i include [0]

  • @deekshasvikatta7673
    @deekshasvikatta7673 Рік тому +4

    my_list3 [1] [0] [1]='b'

  • @tayyab.sheikh
    @tayyab.sheikh 2 місяці тому +1

    I have a question Jaspreet Sir! Why list's index starts from 0 and not 1?

    • @faithndema
      @faithndema 2 місяці тому

      Python indexing is set to start at 0 by default.

    • @nkundizanaabbas3006
      @nkundizanaabbas3006 26 днів тому

      It is offset from the starting point. The first element is at zero offset from the starting point

  • @djrkm9281
    @djrkm9281 5 місяців тому

    how do I access an individual char from a multi-dimensional list? so if I want to access the N in Neso? is my_list [1] [1] ?

  • @mohammedhamad1513
    @mohammedhamad1513 2 місяці тому +1

    my_list3=[1][0][1] the output is b

  • @jagsank1k2
    @jagsank1k2 4 місяці тому

    print(my_list3[1][1])

  • @mdazimuddin232
    @mdazimuddin232 3 місяці тому

    my_list3=[[1,2,3],[['a','b','c'],5,6]]
    print(my_list3[1][0][1])
    output # b

  • @priyamondal6820
    @priyamondal6820 3 місяці тому

    list3 = [[1,2,3],['a','b','c'], [5,6]]
    print (list3 [1][1])

    • @priyamondal6820
      @priyamondal6820 3 місяці тому

      or
      list4 = [[1, 2, 3], ['a', 'b', 'c'], 5, 6]
      print (list4 [1][1])

  • @tylerfarless1139
    @tylerfarless1139 3 місяці тому

    Answer : my_list3[1][0][1]

  • @shaiksameer204
    @shaiksameer204 2 місяці тому

    my_list=[[1,2,3],"abc",[4,5,6]]
    print(my_list[1][1])
    Output
    b

  • @baguidybachmar586
    @baguidybachmar586 10 місяців тому +4

    Mylist_3 [1] [1]

    • @lionelfaith3646
      @lionelfaith3646 10 місяців тому +1

      it's false m your output will be: [5].
      remember in python index starts at 0 and it's my_list3 not My_list3

  • @rita_martha
    @rita_martha 3 місяці тому +1

    my_list3[1][0][1]=b

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

    The correct answer is;
    my_list3 = [ [1, 2, 3], ["a", "b", "c"], [5, 6] ]
    print( my_list3 [1] [1])

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

    Correct answer is : my_list3[1][0][1]
    [1] access the second list in my_list3
    Then we see at [1] there are 2more lists,so if we want to access "b" we need to access the first list by [0]
    And followed by the element we want to access [1]

  • @dheerajnarote8344
    @dheerajnarote8344 3 місяці тому

    my_list = [[1,2,3], [['a','b','c'], 5,6]]
    print(my_list[1][0][1])
    ans:- b ;)

  • @sunilkunkekar7383
    @sunilkunkekar7383 4 місяці тому

    my_list =[[1,2,3],['a','b','c'],5,6]
    k= my_list[1][1]
    print(k)

  • @danielquarshie5235
    @danielquarshie5235 8 місяців тому +2

    The answer is:
    my_list2[1][0][1]

  • @Raja-tt4ll
    @Raja-tt4ll 3 місяці тому

    Nice

  • @malikcomputer2925
    @malikcomputer2925 5 місяців тому

    my_list = [1,2,3],['a','b','c'], [5,6]
    print(my_list[1][1])

  • @zeeshanyounas855
    @zeeshanyounas855 4 місяці тому

    my_list=[[1,2,3],['a','b','c'],[3,4,5]]
    print(my_list[1][1])

  • @thakuranujbhati1565
    @thakuranujbhati1565 4 місяці тому

    Answer of HW -- print(my_list3[1][0][-2])😅Sorry for taking negative indexing only i like that

  • @frames__time
    @frames__time 9 місяців тому +3

    print(my_list[1][0][1])

  • @shoxjaxonnurxonov2984
    @shoxjaxonnurxonov2984 5 місяців тому

    my_list3 = [[1,2,3],[['a','b','c'],5,6]]
    list3 = my_list3[1][0][1]
    print(list3)
    thank you for support, good luck

  • @adinarayananaragani9977
    @adinarayananaragani9977 4 місяці тому

    Print(my_list[2])

  • @KusumLata-iu6xd
    @KusumLata-iu6xd 6 місяців тому

    print(my_list3[1][0][1]) giving error of indexError: string index out of range. the correct answer is [1][1]

    • @desixhorra
      @desixhorra 4 місяці тому

      answer is[1][0][1]

  • @Mareamhager
    @Mareamhager 6 місяців тому

    my_list = [[1,2,3],[["a","b","c"]'5'6]]
    Print (my_list[1][0][1])

  • @Harbingersknight21
    @Harbingersknight21 4 місяці тому

    Answer to homework question :
    print(my_list3[1][0][1])

  • @wordslink2623
    @wordslink2623 Рік тому +1

    My_list 3[2]

    • @lionelfaith3646
      @lionelfaith3646 10 місяців тому +1

      syntax error because my_list3 has only 2 elements within it, it means the index of a last element is [1].

  • @user-en9tz8np8o
    @user-en9tz8np8o 6 місяців тому

    My_list[1][0][1]

  • @RosesAreAlsoPink
    @RosesAreAlsoPink 7 місяців тому +5

    Answer to the Homework Question: print(my_list3[1][1])

    • @arjunyakala6851
      @arjunyakala6851 7 місяців тому +3

      Wrong...print (my_list3 [1][0][1])

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

      The above answer is correct according to the explanation given in the video, although why did we add [0] in between?

    • @Engineer508
      @Engineer508 6 місяців тому

      ​@@samaira6031to access first list of second list

  • @hemlatamukati2303
    @hemlatamukati2303 5 місяців тому

    b = [["a","b","c"],5,6]

  • @brindham4073
    @brindham4073 11 місяців тому +1

    print(my_list[1][1])

    • @lionelfaith3646
      @lionelfaith3646 10 місяців тому +1

      syntax error my_list is undefined, even if it was my_list3[1][1]=5 not 'b'

  • @kaushikshiva7852
    @kaushikshiva7852 5 місяців тому +1

    lists=[[1,2,3],["a","b","c",5,6]]
    print (lists[1][1])

  • @tajgill7720
    @tajgill7720 6 місяців тому

    print(my_list3[1][1]) homework b

  • @ECEKOTESWARARAOM
    @ECEKOTESWARARAOM Рік тому +1

  • @tonystark33748
    @tonystark33748 6 місяців тому +2

    # Homework-Problem
    # Q -> Access value "b"?
    # Code:
    my_list3 = [[1, 2, 3], ['a', 'b', 'c'], [5, 6]]
    value_b = my_list3[1][1]
    print(value_b)

  • @tayyab.sheikh
    @tayyab.sheikh 2 місяці тому +1

    I was here to comment the correct answer but already everyone has posted it.

  • @rasmusa9212
    @rasmusa9212 Рік тому +3

    mylist3[1][1]

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

      your output : 5. wrong answer and it's my_list3 not mylist3 (mylist3 is undefined)

  • @user-en9tz8np8o
    @user-en9tz8np8o 6 місяців тому

    My list3[1][0]

  • @user-en9tz8np8o
    @user-en9tz8np8o 6 місяців тому

    My list3[1][0][1]

  • @tharunkumar8430
    @tharunkumar8430 8 місяців тому

    my_list [1] [0] [1]

  • @captaintariq6350
    @captaintariq6350 4 місяці тому +1

    my_list = [[1, 2, 3], ['a', 'b', 'c'], [5, 6]]
    print(my_list[1][1])
    print(my_list[-2][-2])
    print(my_list[1][-2])
    print(my_list[-2][1])

  • @kishaniglesias
    @kishaniglesias 6 місяців тому

    my_list3 [1][1]

    • @lmsphantom5615
      @lmsphantom5615 6 місяців тому

      wrong, you need to access the 1st mem block and then0th index of the sub-mem block and then 1st index of the sub-memblock, it would be something like this: my_list3[1][0][1]

  • @user-xn2es9im9l
    @user-xn2es9im9l 6 місяців тому

    List =[[1,2,3],[['a','b'],[5,6]]]
    Print(list[1][0][1])

  • @ketoki69
    @ketoki69 Рік тому +1

    [1][1]

  • @cybershrajal
    @cybershrajal 3 місяці тому

    Sure, I can explain it simply!
    First, let's break down the code:
    mylist = [[1, 2, 3], [5, 6, ['a', 'b', 'c']]]
    This line creates a list called `mylist` containing two lists inside it. Each of these inner lists contains numbers and another list.
    Now, let's break down the indexing part:
    print(mylist[1][2][1])
    - `mylist[1]` refers to the second element of `mylist`, which is `[5, 6, ['a', 'b', 'c']]`.
    - Then, `mylist[1][2]` refers to the third element of that second list, which is `['a', 'b', 'c']`.
    - Finally, `mylist[1][2][1]` refers to the second element of that inner list, which is `'b'`.
    So, `print(mylist[1][2][1])` will output `'b'`

    • @hepp00
      @hepp00 22 дні тому

      When you type [1] [2] youll get 6. So you must type [1][0]

  • @user-hr1fj2dh6j
    @user-hr1fj2dh6j 3 місяці тому

    my_list = [[1, 2, 3], [['a', 'b', 'c'], [5, 6]]]
    print(my_list[1][0][1])

  • @nithishm6619
    @nithishm6619 7 місяців тому +1

    my_list3[1][0][1] = 'b'

  • @atnafunega2206
    @atnafunega2206 4 місяці тому

    my_list3 = [[1,2,3],[["a","b","c"],5,6]]
    print(my_list3[1][0][1])

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

    my_list3[1][0][1]=b

  • @ganasindu616
    @ganasindu616 9 місяців тому

  • @techfriend1144
    @techfriend1144 3 місяці тому

    my_list = [[1, 2, 3], [['a', 'b', 'c'], 5, 6]]
    print(my_list[1][0][1])

  • @RonarRasin-on7nk
    @RonarRasin-on7nk 6 місяців тому

    my_list3 = [[1, 2, 3], [['a', 'b', 'c'], 5, 6]]
    print(my_list3[1][0][1])