 What's up guys root of the now here bringing you back with some more Python tutorials now dude look at this check out my terminal here Do you see this do you see this right now? 32 Python tutorials and you are on at your 33rd. Look at that dude. Look at that. Give me a high five right now right now That was our high five. All right, whatever. Let's jump into idle here Let's get started and I'm gonna create a new program. Let's see this can be a filed up Python as always I'm just saving on a other monitor So you couldn't see what I was doing there get our shebang line It's been environment. I think we don't want to slash there not a period and now let's create a new class Called this one base. I'm gonna try and set up that little skeleton program like we did yesterday And the blast tutorial it might not be yesterday in your case. Who knows who knows? Okay, we got our constructor and we're just gonna have them print. Hello Actually, that's a lot of L's not O's Hello Yeah, that's all let's do um new objects Don't ever don't ever do that when you're programming Don't ever whistle or anything like that because you're not gonna be able to focus. Hello. There you go All right, so now that we've got that set up. Let's create something new here. Let's create a We're gonna be working with today is the idea of passing in dictionaries as parameters and now this is kind of similar or at least a little bit similar It's what we were talking about in the last tutorial passing in tuples as parameters with dictionaries you can uh You can assign keys to it while you're calling the function. So let's just type in a Book now notice that our variable that we're passing in has two Proceeding asterisks with the tuple that we had in the last tutorial. We only had one preceding asterisk So now we're working with two and that's how we're gonna be able to denote things So what we're gonna do is uh, we're gonna go a little bit more in-depth with Understanding dictionaries today too. So let's go for key and value. We're gonna be looping for two Variables while we're reading while we're reading this dictionary for key and the value in the dictionary And on the book sorry and look at we're using a comma here to separate these two variables Just like we would be normally doing in like a parameter or an argument list and that sort of thing So for the key and the value in book now book is a dictionary But we're able to use a function with the dictionary called iter items or it here items And that's gonna allow us to iterate To go through every single item or thing that is inside that dictionary So let's get our colon here and security code block and let's start typing. Let's display print The string of key Because we don't exactly know what the person or the program is gonna be typing in for a key It could be an integer it could be a string We don't know and we're just gonna say refers to No add on the string variable a value So this should work We get the both the key and the value of the key right so when you have remember when you had that dictionary You had something that referred to something else something that linked to another value something that associated itself with another value And that's exactly what we're doing here except we're passing it in as a function with a different sort of with a different sort of idea here So now if we run this we can Print book Now remember because we haven't set anything up. We haven't passed in any values for this It's it's gonna run. Okay, because it's an option to have things inside of a dictionary or list like that or a toppler Any sort of variable like that any sort of data type You don't really have to have anything in there You can have an empty data type and in this case when we're not passing in any arguments That's exactly what's gonna happen So if we print out book though, we might just get an empty character set Let's try let's run a five and there you go you get absolutely nothing inside that list But now let's take a look at it when we're actually initializing the function when we're calling the function What we're gonna do is let's say The Raven actually Because what you have to do when you're calling new things in this With it while calling a dictionary inside of a function what you're gonna be doing is passing in Variables that are going to ask that they're going to act as strings for the key. So if you typed in a poem Poem can equal The Raven how about that now we could have Sonnet sonnet can equal how about evolution starts with an R with an R We can type in like novel We can call this one the Odyssey That's sort of thing. I don't know if I spelled that right Who cares? But yeah, what you're gonna be where you're gonna be setting up is The variable name and you're going to be initializing these things inside your function call So you've got poem you got son and you've got novel and these are all going to associate with the value of the string That we type in obviously it doesn't have to be a string it can be an integer it can be your float It can be anything it could be an object for all we know and But that's exactly how it's gonna work. So now if we run this poem is going to be treated as our key and then The Raven is going to be treated as our value and this is going to go through every single time So let's try it poem the Raven sonnet evolution starts in our novel the Odyssey and that sort of thing Poem refers to the Raven sonnet refers to evolution starts with an R and novel refers to the Odyssey So see we're taking a string value of what we have here of what we pass in as our key If we tried to do this. I'm curious of what would happen if we try to do this without casting it as a string Will it understand that of course it will it will default think of it as a string if we turned it to an integer Obviously, we're gonna get a problem here because there aren't any integers inside that but You get the idea it does take the key in the dictionary as a string and it's using it as a strange Syntax though because we're using an equal sign or an assignment operator rather than that colon that we're used to But that's the way it works people I mean item again I myself don't use this too often But you do have to remember some crucial things in this video here the way that you assign things while you're calling a dictionary into the Function the way that you pass in the two asterisks in the variable name when you're defining the function and Being able to loop through keys and values when you're looking through a book I'm sorry a dictionary And in our case it's a book and the function that you want to use is it or items if we created a Dictionary in the interactive shell we can see some of the functions that we'd be able to call Let's just try and select that here we go come on come on control C. There we go Stroll V. Okay, cool. So we get a book in this case book is equal to that Inside of our interactive shell we can do book and we can do we can call all these functions on here And some of these are being able to iterate through the keys some of them are able to iterate through the values and in our case Itter items allows you to to iterate through both the key and the values So there are a lot of interesting things you can do with loops dictionaries lists and any any sort of data type like that and using that logic, but hey I think I'm all done rambling. Thank you guys for watching. Thank you for listening It'd be cool if you could give me a comment. Maybe maybe like the video maybe subscribe I don't know. It's whatever you want to do, but thanks for watching again guys, and I'll see you in the next tutorial