Open jonasreinsch opened 1 year ago
@jonasreinsch set
is unordered https://docs.python.org/3.11/library/stdtypes.html#set-types-set-frozenset
@jonasreinsch
set
is unordered https://docs.python.org/3.11/library/stdtypes.html#set-types-set-frozenset
@ahasan85 yes, but sorted
then returns an ordered / sorted list.
Just try it out:
>>> sorted(set(list(''.join(['hello', 'my', 'friends']))))
['d', 'e', 'f', 'h', 'i', 'l', 'm', 'n', 'o', 'r', 's', 'y']
>>> sorted(set(''.join(['hello', 'my', 'friends'])))
['d', 'e', 'f', 'h', 'i', 'l', 'm', 'n', 'o', 'r', 's', 'y']
Small code simplification:
the line
can be simplified to
because
sorted(...)
accepts anyiterable
andset(...)
returns aniterable
.I noticed this in your building makemore video (thank you for that!) at 15:56