A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing


  • 3 years ago

Hi, I have a query about problem 5 on Quiz 1. The solution says: v1 = v1[:] v2 = v2[:] at the beginning. Can anyone explain to me why we need to do this? Thanks

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

    post the complete problem/solution that would prevent the original list object from being mutated. are v1 and v2 function arguments? copy = original[:] is a way to copy a list, it creates a completely new list object and assigns it to the variable on the left side of the equal sign http://henry.precheur.org/python/copy_list http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables http://effbot.org/pyfaq/how-do-i-copy-an-object-in-python.htm it helps to reference the course you are taking - ppl taking OCW 6.00 (2008) and OCW 6.00c (2011) and sometimes the edX 6.00 post here - same basic course with similar problems and different pset numbers. please use a code pasting site to post code: - http://dpaste.com - http://pastebin.com - https://gist.github.com/ - http://pastie.org - http://codepad.org - http://ideone.com - http://www.repl.it/ paste your code there and post the link here. select Python syntax highlighting when u paste.

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

    Thanks very much. I see the point and I will post questions more clearly next time.

  3. 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...


  • 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.