A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

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?

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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!

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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/

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.