In a message of Sun, 22 Nov 2015 21:58:35 +0100, marcus lütolf writes:
>dear pythonistas
>
>i have written the code below for identifying tuples occurring twice or more
>times in the list of tuples called "flights".
>1. Question: How can i modify this code so it does not matter which string is
>first and which is second or (h,i) == (i,h) respectively ?
This may be an indication that you have got the wrong datatype. It may be
that you would be happier with a set.
>>> s1={'Stockholm', 'Berlin'}
>>> s2={'Berlin', 'Stockholm'}
>>> s1 == s2
True
If you need a tuple later -- for instance you want to use the tuple as a
key in a dictionary later, because you cannot use the set directly
>>> tuple(s1)
('Stockholm', 'Berlin')
>>> tuple(s2)
('Stockholm', 'Berlin')
>>>
Laura
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor