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.
This is so simple. I wish my class actually taught me this instead of just expecting me to know it. Thanks dude!
Is there a way you can continuously append into the 2d array? something like in a while loop?
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.
me too
This video really helped me understand 2D arrays. I was struggling prior to watching this lol
Thank you sooooooooooo much. I've been looking for videos like this for ages
Damn this was useful haha thanks for helping with my classes dude.
Just what i needed
How can return unnestted elements(individual [1d]lists) from that 2d list in a function?
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] ??
This guy is amazing! yall should check out his other py vids! very helpful!
Mike,thank you so much for the excellent job! It is very useful for me to understand two dimensional lists in Python.
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 ?
Love learning from you!!! You do a great job breaking things down and delivering them in simple language. Thank YOU!
Dang you deserve a million subs for doing this
Can you match or compare two nested list with the same value or element
Hi, how to append two matrices side by side in python? Please anyone, I require it urgently.. Thanks
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!
arr = [1, 2, [3, 4], 'a', 'b']
print arr[4: 0: -2]
Ans) ['b', [3, 4]]
Anyone can explain what the heck is this
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
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
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??
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?
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:
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 . . .
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
Thank you. Very helpful.
Thanks bud.
"miked"
hmm
seems slightly familiar
Mike is so good at teaching
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.
THANK YOU I LOVE U
How do I access to only certain values inside of my nested loop. for.ex: values = or >100
Thanks!
did you end up finding out?
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
how to create a nested list with from single list?
How do i change 1 element of the 2d list?
This is awesome, thank you :)
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?
Hey in the code section of this video on your website, you have written
for row in col:
instead of
for col in row:
I have just wanted to write the same)). I think, Mike did this mistake intentionally to make students think))
bro thats okay but how to add list in a nested list
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
What brackets you used
maybe you forgot comma between the lists?
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.
Very helpful. Thank you!
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?
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
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.
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!
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?
Very helpful. Thank you.
I swear we learn things easier on UA-cam than in school. Cancel colleges lol
if you can clear my doubt then it would be a great help
what if the list is not user defined?
this is so simple
Holy crap I used to thi k Mike and TechWithTim were the same guy
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
Your videos are really great, I have one question like how can access individual rows
You rock! Mike!
you might want to do Frequency distribution table😊😊using python.
How do you add the numbers in the column and output it separately?
thank you , very helpful , but how about if the list was string
Bro you so fucking good
wow so cool
thank you sir😍😍😍
Oh my gooodness, I can't believe it's that simple. Thank you!
Your are f...ing AWESOME ! You explain for dummies like me to understand. Thanks man ! You got a +1 Subscriber :)
How can you make a 2d array from taking user input ?
ua-cam.com/video/dsLpJxu3ihI/v-deo.html
THANK YOU SO MUCH
MAN I FUCKIN LOVE YOU THANKSS
bro smile too...
thanx for this
how do i access the last item in each list and print?
Thank You!
Thanks !
God Bless
can you name each list within a list?
Straight legend! such an easy and great explanation, thank you!
how to loop values into a multi-dimensional list?
🙏
Do you work at nasa?
Thanks Mike you are making great things
thank you for this!
Excellent, clear, concise and to the point!
Thank you!
i want that shirt
nice but... This is the simple stuff. How would you init an n-dimensional "array: all to 0?