May-18-2017, 02:07 AM
May-18-2017, 02:18 AM
That "list" notation is common for indicating that it's optional. So you provide either a number, or nothing.
Other readers can see https://docs.python.org/3.7/tutorial/dat...tures.html for an example.
Other readers can see https://docs.python.org/3.7/tutorial/dat...tures.html for an example.
May-18-2017, 03:26 AM
so
[[]]
can mean an optional empty list. or for more fun [[n]]
can mean an optional list with n as its only member or a list that can optionally have a member n or be empty.May-18-2017, 03:48 AM
I'd have to see a real example.
May-18-2017, 04:34 AM
(May-18-2017, 03:48 AM)micseydel Wrote: [ -> ]I'd have to see a real example.
how would i do that? i'm just making mixed interpretation of [] ehen there are two of them, one interpreted as a list spec and the other meaning optional.
May-18-2017, 07:57 AM
You pop(index) out of the sequence
>>> l = list(range(1, 21)) >>> l [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] >>> for index, _ in enumerate(l): ... print(l.pop(index+1)) 2 4 6 8 10 12 14 16 18 20 >>> l [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]