text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
into a list maybe do something to them | 1,506.179 | 3.421 |
maybe forcing them to uppercase or | 1,508.159 | 3.541 |
lowercase or the like and then sort and | 1,509.6 | 3.78 |
print out each item | 1,511.7 | 3.18 |
let me pause and see if there's any | 1,513.38 | 3.84 |
questions now on file IO reading or | 1,514.88 | 6 |
writing or now accumulating all of these | 1,517.22 | 7.079 |
values in some list hi is there a way to | 1,520.88 | 5.94 |
sort the files but instead if you want | 1,524.299 | 5.641 |
it from alphabetically from A to Z is | 1,526.82 | 5.219 |
there a way to reverse it from zet to a | 1,529.94 | 4.38 |
is there a like a little extension that | 1,532.039 | 3.661 |
you can add to the end to do that or | 1,534.32 | 2.88 |
would you have to create a new function | 1,535.7 | 4.079 |
if you wanted to reverse the contents of | 1,537.2 | 5.4 |
the file yeah so if you instead of | 1,539.779 | 4.921 |
sorting them from a to z in ascending | 1,542.6 | 3.6 |
order if you're one of them in | 1,544.7 | 2.76 |
descending order | 1,546.2 | 4.26 |
is there an extension for the there is | 1,547.46 | 5.219 |
indeed and as always the documentation | 1,550.46 | 4.079 |
is your friend so if the goal is to sort | 1,552.679 | 3.48 |
them not in alphabetical order which is | 1,554.539 | 2.88 |
the default but maybe reverse | 1,556.159 | 2.941 |
alphabetical order you can take a look | 1,557.419 | 3.181 |
for instance at the formal python | 1,559.1 | 3.36 |
documentation there and what you'll see | 1,560.6 | 3.9 |
is this summary you'll see that the | 1,562.46 | 3.839 |
sorted function takes a first argument | 1,564.5 | 4.08 |
generally known as an iterable and | 1,566.299 | 3.841 |
something that's iterable means that you | 1,568.58 | 3.479 |
can iterate over it that is you can Loop | 1,570.14 | 4.139 |
over it one thing at a time what the | 1,572.059 | 4.141 |
rest of this line here means is that you | 1,574.279 | 3.9 |
can specify a key like how you want to | 1,576.2 | 3.959 |
sort it but more on that later but this | 1,578.179 | 4.321 |
last named parameter here is reverse and | 1,580.159 | 4.441 |
by default per the documentation it's | 1,582.5 | 4.559 |
false it will not be reversed by default | 1,584.6 | 4.439 |
but if we change that to true I bet we | 1,587.059 | 4.021 |
can do that so let me go back to vs code | 1,589.039 | 4.14 |
here and do just that let me go ahead | 1,591.08 | 4.199 |
and pass in a second argument to sorted | 1,593.179 | 4.74 |
in addition to this iterable which is my | 1,595.279 | 5.041 |
names list iterable again in the sense | 1,597.919 | 4.86 |
that it can be looped over and let me | 1,600.32 | 5.58 |
pass in Reverse equals true thereby | 1,602.779 | 5.341 |
overriding the default of false let me | 1,605.9 | 4.74 |
now run python of names Dot pie and now | 1,608.12 | 5.039 |
Ron's at the top and draco's at the | 1,610.64 | 4.68 |
bottom so there too whenever you have a | 1,613.159 | 3.301 |
question like that moving forward | 1,615.32 | 3.3 |
consider what does the documentation say | 1,616.46 | 3.9 |
and see if there's a germ of an idea | 1,618.62 | 3.299 |
there because odds are if you have some | 1,620.36 | 3.299 |
problem odds are some programmer before | 1,621.919 | 4.321 |
you have had the same question other | 1,623.659 | 5 |
thoughts | 1,626.24 | 2.419 |
um | 1,629.36 | 5.22 |
and the second question can we find a | 1,630.7 | 6.7 |
specific name really good question can | 1,634.58 | 4.26 |
we limit the number of the names in the | 1,637.4 | 3.899 |
file and can we find a specific one we | 1,638.84 | 4.8 |
absolutely could if we were to write | 1,641.299 | 4.98 |
code we could for instance open the file | 1,643.64 | 5.34 |
first count how many lines are already | 1,646.279 | 4.861 |
there and then if there's too many | 1,648.98 | 4.799 |
already we could just exit with sys.exit | 1,651.14 | 4.44 |
or some other message to indicate to the | 1,653.779 | 4.321 |
user that sorry the class is full as for | 1,655.58 | 4.74 |
finding someone specifically absolutely | 1,658.1 | 4.28 |
you could imagine opening the file | 1,660.32 | 4.44 |
iterating over it with a for loop again | 1,662.38 | 4.12 |
and again and then adding a conditional | 1,664.76 | 4.56 |
like if the current line equals equals | 1,666.5 | 5.34 |
Harry then we found the chosen run and | 1,669.32 | 4.079 |
you can print something like that so you | 1,671.84 | 3.18 |
can absolutely combine these ideas with | 1,673.399 | 3.721 |
previous ideas like conditionals to ask | 1,675.02 | 4.2 |
those same questions how about one other | 1,677.12 | 6.48 |
question on file IO uh so I just thought | 1,679.22 | 5.6 |
about | 1,683.6 | 5.819 |
this function like uh read all lines and | 1,684.82 | 9.04 |
it looks like it's uh like separate all | 1,689.419 | 7.221 |
the lines by this special character | 1,693.86 | 5.88 |
backslash n but it looks like we don't | 1,696.64 | 6.399 |
need it a character and we we always | 1,699.74 | 7.559 |
trip it and it looks like some bad | 1,703.039 | 7.801 |
design of function why why wouldn't we | 1,707.299 | 7.201 |
just strip it inside this function a | 1,710.84 | 6.18 |
really good question so we are in my | 1,714.5 | 4.86 |
examples thus far using our strip to | 1,717.02 | 4.86 |
reverse uh to strip from the end of the | 1,719.36 | 4.5 |
line all of this white space you might | 1,721.88 | 4.26 |
not want to do that in this case I am | 1,723.86 | 4.679 |
stripping it away because I know that | 1,726.14 | 4.32 |
each of those lines isn't some generic | 1,728.539 | 4.02 |
line of text each line really represents | 1,730.46 | 5.04 |
a name that I have put there myself I'm | 1,732.559 | 4.681 |
using the new line just to separate one | 1,735.5 | 4.08 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.