Python Forum
What is distinction between 'sent3' and 'set(sent3)'?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is distinction between 'sent3' and 'set(sent3)'?
#4
What does set_a > set_b even mean? Lists and tuples compare element by element, but since a tuple has no order, it makes no sense to compare elements. You say "distinct token total", but what does that mean? setA > setB if setA has more things? That is not the basis of comparison for any of the other collection types.

To be honest I am surprised that > and < don't throw an error when used with sets. The result is meaningless. Try this:
x = {'a', 'b', 'c', 'd', 'e'}
y = {'f', 'd', 'c', 'b', 'a'}
print(x > y)
print(y > x)
print(x == y)
Equal works if both sets have the same elements, but the code above returns:
Output:
False False False
Reply


Messages In This Thread
RE: What is distinction between 'sent3' and 'set(sent3)'? - by deanhystad - Jul-09-2020, 03:51 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020