Thelistis a typeofdata, justlikestringsandintegersthatwe'veseensofaronitsusedtostore a listofthings, andit's similarto a raiseinsomeotherlanguages, likeJava.
Solet's take a lookatoneexampleheretodefine a listyoucanjustwrite a eco's openscarbracket.
Threecommatangcommaminusoneclosesquarebracketsonthislinemeansdefine a newlistwiththeelements 3 10 onminusoneonassignedthislisttothisviableeight.
Andjust a quicknoteherethatyoucandownloadthissimplefilebygoingtosee a snowthatioslashpythonfor.
Youcoulduse, forexample, partcharm, whichis a goodidea.
HeforPython.
Nowlet's runthecellon.
Oncewerunthecell, A shouldbedefined, solet's print a withprint.
Prenticeis a andweseethatweget a listwiththeelements.
3 10 onminusone.
Whatifwewantedtoaddanitemtothislist?
Youcandothatwith a dotupendparentheses.
One.
Thismeans a pen.
Theitem, thenumberonetothelist.
Eight.
Sothisdotnotationis a prettycommononeonyou.
Seemoreofthatlaterinthiscourse.
Sothisfunction a penisbasically a predefinedfunctionthatyoucanuseonthelistdatatype.
Soagain, that's a dot a penparentheses.
One.
Let's executethiscellon.
Onceweprint A, youseethatthenumberonehasbeenaddedtothislists.
SooneinterestingthingaboutthePythonlist, whichisdifferentfromsomeotherlanguageslikeJava, isthatyoucanmixtypesin a singlelistsoyoucouldhave a listcontainingnumbersaswellas a string.
Let's seehowthatworksby a pendingthestringHellotothelist A ways.
Sowe'redefining a newviablecalledtempfor a temporaryviable, whichisgoingtorefertowhatbesquarebracketzerorefersto, whichisthisone.
Andthenyoucanwrite B squarebracketzeroeco's bescarbuckets, too.
Sowe'resayingthefirstcompartmentshouldnowrefertowhateverthethirdcompartmentreferstobecause, like I said, theindexforthefirstitemiszeroontheindexfortheseconditemisoneontheindexforthethirditemistoo.
As a result, afterthesepiecesofcode, wehavethedesiredresult.
Sothat's a listwiththefirstcompartmentreferringtotheviolin, MicrosoftonthesecondelementbeingAppleandthethirdelementbeingbanana.
Thestring.
Okay, let's makesurethatmethodworksincode.
First, printthecurrentlistwithprintbeandwehaveBanana, AppleandMicrosoft, justlikewesaw, willfirstdefine a temporary, viableWhere's tempEco's bescarBucketzeroandthen a signthevalueoff B Squarebracketstotobescrappergetszeroandthenassignwhattemplereferstotobesquarebrackets, too.
Andthenattheend, we'regoingtoprint.
Beokay, that's correct.
WehaveMicrosoftAppleBanananow, andactuallythere's a shortcutforthis, andthat's bescrubber.