#๐Ÿ”’ Python complexity

12 messages ยท Page 1 of 1 (latest)

tiny sapphire
#

What complexity is membership testing x in y when y is a list and when y is a set?

spice oarBOT
#

@tiny sapphire

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

stable elbow
past swift
sinful flower
#

@tiny sapphire Karma gave you the correct answer. Did you have any other questions?

tiny sapphire
vale plaza
#

!d set - everything is hashed (under the hood); technically its like comparing with a hashmap.

spice oarBOT
#
set

class set([iterable])``````py

class frozenset([iterable])```
Return a new set or frozenset object whose elements are taken from *iterable*. The elements of a set must be [hashable](https://docs.python.org/3/glossary.html#term-hashable). To represent sets of sets, the inner sets must be [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset) objects. If *iterable* is not specified, a new empty set is returned.

Sets can be created by several means:

โ€ข Use a comma\-separated list of elements within braces: `{'jack', 'sjoerd'}`

โ€ข Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}`

โ€ข Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])`...
spice oarBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.