 So now we're going to build a function and have it interact with a list. So for this function I'm going to create something called shuffle Numbers Now as that term shuffle you can probably imagine I'm going to shuffle the lump numbers in my list Now, okay, fair enough. We've got this going on One of the things that we need to sort of keep in mind when we're dealing with Lists inside of functions since they are so complex. They could be Thousands of numbers that we're dealing with Python is not going to duplicate those thousands of numbers, but instead it's going to Passed by Reference or pass by reference and what that means is that if we make any changes to numbers It's going to affect the or let me call this a list Any change we make to a list is going to make the same change to The list and what do I mean by that? Let's say for example for I in range Lynn a list I Equals or Times equals 10 That's it. I'm just going to make that my shuffle now. We have a randomly generated set of numbers I'm going to first Do shuffle on my numbers Now there's no print statement because again, we didn't say that there should be a print statement in our code But just take a look at what shuffle said to do Go in to every element inside of a list and multiply it by 10 Well, guess what happens if I come in and Print my numbers all of my numbers magically have changed to that Respective times 10. So it's something that we have to be mindful of This can be beneficial if we're Sometimes working and we we want to manipulate this for example shuffle. I don't necessarily want to What's the word I'm looking for I don't want to necessarily Multiply it by 10 But if I were to shuffle my characters or my numbers around That would be very important to know about so in this case. Let's say again We want to shuffle our numbers well, if we're thinking about this just to Draw this out for a second and let me get rid of that There we are So if we're thinking about just a list of numbers that I want to work with let's say I've got 356 710 So I've got five randomly numbers Each one of those is going to again have some associated index to them Well, when I'm traversing through this so again for I in range Lin and I'll just call this X to shorthand my writing So I is going to be zero one two three four now at each iteration I basically if you think about it want to Make a random decision on those numbers. I need to find a pick a random spot so I'm going to make a temp Idx temp index that is going to be some random number From zero to five not including five Okay, well, that's we're starting to get an idea of where to go here. Let's say for our sake in this first iteration Let's see let me change colors there Let's say for Example we generated a four. Okay, so we want to swap the zero and the four So what would I need to do? Well, I happen to now have that for value So I need to again now Extract out the value at that spot. So temp is now going to equal X at my temp index Again, if we're thinking about that That is now 10 and so now X at sorry X at see my eye Or not yet. Not yet. My apologies X at that randomly generated index is now Got to be equal to my three so X at I and then finally the X at I Would be equal to my temp Okay, so I've drawn this out. What does it mean going into each step again? If we magically assume that we've generated the random number of a four and We're at index zero at this time I first grab whatever the value is at that for so ten Then I say X at again. This is four is now going to be X at zero So I've just changed ten to three and then X at Zero is going to be equal to temp. Well, remember I made temp ten just a second ago, so We're just Utilizing that ten and that three is now a ten Okay, okay. I've drawn it so clearly it works, right? No, let's see that in action. So temp index again, we want to generate a random number so random Dot random zero to how big my list is in this case It may be five characters. It may be in this case ten characters because we generated ten characters How do we figure out the length of a list or the size of a list? Lynn a list Again, that's going to generate some random number and so we're then going to get that element at that random number IDX and then we're going to start swapping around so again a list at that temp index is Now going to equal whatever value was at Or where whatever the value was at our current location and then our current location is Now going to equal whatever that temporary value was okay, so once again, we've Generated some random numbers. They are multiplied by ten right now So there's nothing I can do about that, but I'll load that back in I'm going to shuffle those numbers again. I want you to keep in mind that this is the current order of those numbers Shuffle I shuffled them is 360 going to be my first element. No, it is no longer my first element 110 is my first element and where's 360 it magically went to the end and as you can imagine if I did it again 360 this time went to the first if it did it again 360 is in the middle this time so I can now shuffle through my lists the big thing I do want to recommend though is Sometimes you want this to happen. Sometimes you're not manipulating your list. Sometimes you're working with another list To work off of duplication So some things to kind of think about when you're working off of your lists and whatnot