I'm working on PS2 and am wondering if there is a way to add values derived from a program to a list? Ultimately, I'd need to use this list outside the program as a reference to check values from a separate program against. I haven't seen anything on this in the readings yet. I've just about completed the readings for lecture 3. Can someone point me in the right direction or is this not something you can do in Python?
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Lists objects have an 'append' method that adds elements to them. If you want to use your values in another program you'll have to write them out to a file, and read in the other program.
Lists can also be concatenated by using the + operator, which has a different behavior from the .append function. This is covered later in lecture 6 around 44min. I'm guessing you are looking for a way to keep track of the possibilities to do the calculation for ps2. A copy of the solution I came up with is at http://dpaste.com/533804/ . You can see that I added possibilities to the variable bestSoFar using the + operator. Hope this helps!
thanks knowak and jls. i'll look into both these options. i'm not certain how to read the list back into a separate program so i might come back to get some advice on this later.
Not the answer you are looking for? Search for more explanations.
knowak, any tips on how to read in my list of possible nuggets that can be bought? take a look at my code so far. line 17 is where i try to use the list generated from the top portion of my program. the error message i get indicates that the list isn't callable. i understand what that means but i don't know how to fix it. http://dpaste.com/534695/