Re: My pseudocode to Python?

2019-08-19 Thread Kyle Stanley
> Except 'list' is a bad name to use... Definitely, it's not a good practice to use any reserved names, especially built-in ones. A pretty common substitute I've seen is "ls", but it would be preferable to have something more descriptive of the elements within the list. But, for basic examples, "l

Re: My pseudocode to Python?

2019-08-19 Thread Alan Bawden
Alan Bawden writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > > for i in range( len( list )- 1, 0, -1 ): > > if list[ i ]is None: del list[ i ] > > list = [x for x in list if x is not None] Except 'list' is a bad name to use... -- Alan Bawden -- https://mail.python.org/mailman/lis

Re: My pseudocode to Python?

2019-08-19 Thread Alan Bawden
r...@zedat.fu-berlin.de (Stefan Ram) writes: > for i in range( len( list )- 1, 0, -1 ): > if list[ i ]is None: del list[ i ] list = [x for x in list if x is not None] -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list

Re: My pseudocode to Python?

2019-08-19 Thread Kyle Stanley
Rather than starting with all seven strings in the list and deleting one if a conditional is not true, why not start with 6 elements (with the one in index 3 missing) and insert the 7th element into the third index? >>> mylist = ['a', 'b', 'c', 'e', 'f', 'g'] >>> if x: >>>mylist.insert(3, 'd')

Re: My pseudocode to Python?

2019-08-19 Thread Rob Gaddi
On 8/19/19 10:43 AM, Stefan Ram wrote: Can someone kindly translate my pseudocode to terse Python: list = \ [ 'afaueghauihaiuhgaiuhgaiuhgaeihui', 'erghariughauieghaiughahgaihgaiuhgaiuh', 'rejganregairghaiurghaiuhgauihgauighaei', if x: 'argaeruighaiurhauirguiahuiahgiauhgaeuihi', 'r