text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
input for instance if the user types in | 43.039 | 4 |
an email address whether to your program | 45 | 4.079 |
or a website or an app on your phone you | 47.039 | 3.321 |
might ideally want to be able to | 49.079 | 3.241 |
validate that they did indeed type in an | 50.36 | 3.28 |
email address and not something | 52.32 | 3.36 |
completely different so using regular | 53.64 | 3.399 |
Expressions we're going to have the new | 55.68 | 3.8 |
found capability to Define patterns in | 57.039 | 4.881 |
our code to compare them against data | 59.48 | 4.039 |
that we're receiving from someone else | 61.92 | 3.44 |
whether it's just a validated or heck | 63.519 | 3.441 |
even if we want to clean up a whole lot | 65.36 | 3.36 |
of data that itself might be messy | 66.96 | 4.44 |
because it too came from us humans | 68.72 | 4.48 |
before though we use these regular | 71.4 | 4.399 |
Expressions let me propose that we solve | 73.2 | 5.84 |
a few problems using just some simpler | 75.799 | 5.041 |
syntax and see what kind of limitations | 79.04 | 4.079 |
we run up against let me propose that I | 80.84 | 4.599 |
open up vs code here and let me create a | 83.119 | 4.481 |
file called validate dopy the goal at | 85.439 | 3.801 |
hand being to validate how about just | 87.6 | 3.519 |
that a US users's email address they've | 89.24 | 3.32 |
come to your app they've come to your | 91.119 | 3.04 |
website they type in their email address | 92.56 | 4.04 |
and we want to say yes or no this email | 94.159 | 5 |
address looks valid all right let me go | 96.6 | 5.92 |
ahead and type code of validate dopy to | 99.159 | 5.481 |
create a new tab here and then within | 102.52 | 3.68 |
this tab let me go ahead and start | 104.64 | 4.04 |
writing some code how about that keeps | 106.2 | 4.44 |
things simple initially first let me go | 108.68 | 3.64 |
ahead and prompt the user for their | 110.64 | 3.839 |
email address and I'll store the return | 112.32 | 4.56 |
value of input in a variable called | 114.479 | 5.521 |
email asking them what's your email | 116.88 | 4.8 |
question mark I'm going to go ahead and | 120 | 3.28 |
preemptively at least clean up the | 121.68 | 3.719 |
user's input a little bit by minimally | 123.28 | 4.839 |
just calling strip at the end of my call | 125.399 | 5.121 |
to input because recall that input | 128.119 | 5.401 |
returns a string or a stir stirs come | 130.52 | 5.04 |
with some built-in methods or functions | 133.52 | 3.84 |
one of which is strip which has the | 135.56 | 3.399 |
effect of stripping off any leading | 137.36 | 3.959 |
white space to the left or any trailing | 138.959 | 4.081 |
white space to the right so that's just | 141.319 | 3.64 |
going to go ahead and at least avoid the | 143.04 | 3.72 |
human having accidentally typed in a | 144.959 | 3.121 |
space character we're going to throw it | 146.76 | 3.72 |
away just in case now I'm going to do | 148.08 | 5.84 |
something simple for a user's input to | 150.48 | 5.36 |
be an email address I think we can all | 153.92 | 3.679 |
agree that it's got to minimally have an | 155.84 | 3.759 |
at sign somewhere in it so let's start | 157.599 | 3.72 |
simple if the user has typed in | 159.599 | 3.92 |
something with an at sign let's very | 161.319 | 4.441 |
generously just say Okay valid looks | 163.519 | 3.8 |
like an email address and if we're | 165.76 | 4.04 |
missing that at sign let's say invalid | 167.319 | 4.081 |
because clearly it's not an email | 169.8 | 2.92 |
address it's not going to be the best | 171.4 | 2.919 |
version of my code yet but we'll start | 172.72 | 3.68 |
simple so I'm going to ask the question | 174.319 | 5.2 |
if there is an at symbol in the user's | 176.4 | 5.119 |
email email address go ahead and print | 179.519 | 4.08 |
out for instance quote unquote valid | 181.519 | 3.961 |
else if there's not now I'm pretty | 183.599 | 3.761 |
confident that the email address is in | 185.48 | 5.24 |
fact invalid now what is this code doing | 187.36 | 6.84 |
well if at sign in email is a pythonic | 190.72 | 5.519 |
way of asking is this string quote | 194.2 | 5.88 |
unquote at in this other string email no | 196.239 | 5.321 |
matter where it is at the beginning the | 200.08 | 2.719 |
middle of the end it's going to | 201.56 | 3.08 |
automatically search through the entire | 202.799 | 3.921 |
string for you automatically I could do | 204.64 | 3.56 |
this more verbosely and I could use a | 206.72 | 3.56 |
for Loop or a while loop and look at | 208.2 | 3.92 |
every character in The user's email | 210.28 | 3.679 |
address looking to see if it's an at | 212.12 | 3.16 |
sign but this is one of the things | 213.959 | 3.161 |
that's nice about python you can do more | 215.28 | 4.599 |
with less so just by saying if at quote | 217.12 | 4.88 |
unquote in email we're achieving that | 219.879 | 3.801 |
same result we're going to get back true | 222 | 4.12 |
if it's somewhere in there thus valid or | 223.68 | 4.919 |
false if it is not well let me go ahead | 226.12 | 4.479 |
now and run this program in my terminal | 228.599 | 4.64 |
window with python of validate dopy and | 230.599 | 3.64 |
I'm going to go ahead and give it my | 233.239 | 4.441 |
email address mailen harvard.edu enter | 234.239 | 5.241 |
and indeed it's valid looks valid is | 237.68 | 2.68 |
valid | 239.48 | 2.64 |
but of course this program is | 240.36 | 4.56 |
technically broken it's buggy what would | 242.12 | 5.039 |
be an example input if someone might | 244.92 | 4.319 |
like to volunteer an answer here that | 247.159 | 4.16 |
would be considered valid but you and I | 249.239 | 4.64 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.