 Hey, what's going on guys Roodle and all here and today. We're looking at even more Python code Programming writing software whatever you want to call that we are doing it. We're doing it all up in here today Right now. We're looking at nesting statements in Python on now You can nest statements It doesn't have to be just an if statement it could be any sort of loop or it could be any other sort of test or code block and Really, it's just you know you nest statements It sometimes when you are trying to make things a little bit more logical And you don't want to bother using other keywords or other symbols that might be able to make your life a little bit easier It all depends on style and it all depends on the way you want to display your logic But in this case if you're trying to examine some pieces of complex or like detailed data you might need to nest statements and All that really does it's like it's like putting two or more logical tests and code blocks inside of each other So you can manipulate things more and be able to do more testing and determine new things and that sort of thing So what we're going to do today is we're going to try and build a a really really I Don't want to say primitive Yeah, I feel like primitive might be the best word for it because it's not the greatest But what we're going to try and do is we're going to try and create something that'll see if it'll find a valid email and All it's going to do is it's going to look for the at symbol and a period in the email It's not going to try and find any positions though But it's going to use that in the operator that we that we learned about in a few tutorials back because that's the membership Membership operator. I'm sorry. I'm falling asleep here. Well, I'm making a tutorial But yeah, all we're going to do is use that we're going to chest For Boolean variables inside of a function. We're going to be using some input We're going to be doing some output stuff So it's going to be pretty sick and you can see it on the left-hand side there But I'm going to walk you through it as you always and let's give it a go Let's get art'll start it up and I'll create a new program I'm going to get my shebang line going on And here we go First of all, I'll say hello to the world because if I don't say hello to the world Sometimes it gets angry at me. Yeah, and I don't I don't get anything nice The world puts like coal in my stocking But I'll save this as file.python overwrite it as usual and let's get started So what we're going to be doing is creating an Let's see an email is valid function and we're going to pass in an argument email Email is going to be a string in our case, at least more likely So let's do some testing. Let's test if we find an at symbol inside the email variable That we're getting that we've been passed And if we don't see that though We're gonna have a problem. We're gonna have to say Prince I don't see that I don't see the the at symbol here It doesn't look like your email address is valid And what we're gonna do is what we're gonna return and remember that return breaks out of a function No matter where it is. So it's gonna return false So we can do like an if we're if we're ever testing later on We can do like if email is valid and then we can pass in the email address and we can get a yes Or no answer. It's just like the way bolding should be used. So that's kind of nice Now we can do up and we can go back up here into our initial if statements If the at symbol is an email and we can create a new one We can nest another if statement in there if we find a period inside the email and we can continue to process If we don't Let's get back here to our correct indentation We can do another similar thing. Let's go right up here and print that all out I don't see the the period here It doesn't look like that the program is is is good It doesn't look like that the email is valid is what I'm saying But if we do find those things we can just say, yeah, I mean, I guess the email looks out to me And then we can return true because we did find what we wanted to we found the at symbol And we found the period but if we if we were doing this like real big and official We might want to test for the position We might want to test to make sure it's like a dot-com or a dot-net or a dot a dot-org or whatever you Whatever you might find we can test for other countries like dot In case you had a different You know end of the URL I can't think of the name right now forgive me, but that's all So in our case email can be Raw input so the user is going to be able to put in what they feel like is an appropriate email Please enter an email So we're gonna be running this function and Then we can start up a new if statement and we can use that Boolean sort of like Style that we wanted to have that we were aiming for if the email is valid if this returns true Which it's that's the condition that we're gonna be looking for here. We can say Success If it's not though, we have a little bit of a problem here you can say a Printed failure and there's our little program All it does it has our it has this little function that it's going to test for some things inside of a string if it finds them It'll it'll do what it needs to do it'll say okay That's fine if it doesn't find them it's gonna break out of that and you have two different cases here So let's let's give it a go. Let's try and run it Hello world, please enter an email. Okay. Um, let's try been a Billy Bob And I don't see anything there. I don't see the at symbol so it's just gonna give up try it one more time Let's type in a Billy Bob at Let's say a Internet Billy Bob at the internet If I can type I don't see the dot here. Okay, so we'll try it one more time Billy Bob at the internet dot World which doesn't make any sense because it's not really a real place, but let's try it anyway It finds exactly what we need to so it looks valid. It seems valid But we haven't tested this the way a real like a good programmer would but I'm trying to use the in statement So you guys are using things that you know so far because I haven't told you about any of their functions That might be able to help you determine where things are whether it starts or whether it ends with a certain string and that sort of thing But yeah, this is the way that it should be it's testing if if Else else it's nesting these ideas and these thoughts together And that's what's going to be able to allow us to manipulate this data and and look at it more in depth And that's exactly what we're trying to do here with these nesting conditional statements We've got our function that works fine. We've got Boolean variables. So that looks good and And it it's it's precise it knows, okay It's looking for the the at symbol it's looking for the dot and that sort of thing It's it's it's versatile too. You could it can have the user type in whatever they think the email should be So I think we've done a good job here I think we've covered a lot of ground and some of our concepts and some of our ideas and we still got the point across Okay, now we're gonna try and nest some statements together. So I think that's all I Hope you guys are able to understand this though It's just the idea that we're mixing two things together two or more things together You can do you can nest as many things as you feel like you need to and they don't even have to be if statements But that is really all that I'm trying to get to cross to you guys in this video So I think I'll sign off here. Thank you guys for watching. Thank you for listening I hope that you really enjoyed this video I hope we can help you out and your new Python adventure and it'd be nice if you could give me a like Maybe a comment maybe subscribe. I don't know. It's uh, it's just an idea. You can take it or leave it But I'll see you guys in the next tutorial