A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 4 years ago

I have trying to figure out how best to compare two tuples and return the values that do not match (for PS3d). Any suggestions?

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

    My suggestion is to work with lists and convert it to a tuple when you need it, or vice versa. This is for two reasons. First, lists are mutable and, therefore, if you need to change things around then you can do so with lists but not with tuples. Second, more operations and methods are supported for lists than tuples. If I am receiving a tuple as a parameter for a function, for example, then I will convert it to a list, do whatever processing I need to do, and then convert the list(s) to tuple I necessary. For example, def someFunction(tup) t=list(tup) #do whatever processing i need against the list x=tuple(t) return x

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

    something like this?? http://dpaste.com/693397/

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

    Surely not the most efficient way, but it appears to work - http://dpaste.com/693792/

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

    Hello, there is also list comprehensions !!! http://docs.python.org/tutorial/datastructures.html#list-comprehensions So it will be just like http://dpaste.com/hold/694119/ Voila !!!

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

    Well den2042, doesn't that just make it too easy :) thanks!

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