Letter replacer - suggestions?

inhahe inhahe at gmail.com
Mon Dec 7 14:58:45 EST 2020


Besides what others have said (especially re using a dict instead), I think
it's unpythonic/can result in unexpected behavior to change a list as it's
being iterated over. Your modified word_list should be a separate list, I
think.
Also, if you use enumerate(), you won't have to use .index and it would be
more efficient.
And I'm not sure what the 'while True' accomplishes. Seems it would put it
in an endless loop? If the 'while True' were in the beginning of the
program, before the inputs, it would make more sense. (And in that case
you'd probably want to break the loop if `word` is empty)

On Mon, Dec 7, 2020 at 10:51 AM Bischoop <Bischoop at vimart.net> wrote:

>
> I worked on my wee script that replaces a letters: https://bpa.st/OYBQ .
> I would like to have some suggestions about the code from more
> experienced programmers, the code does work and do its job but perhaps
> could work in a better way.
>
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list