How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

Richard Damon Richard at Damon-Family.org
Thu Aug 6 17:19:13 EDT 2020


On 8/6/20 4:07 PM, 2QdxY4RzWzUUiLuE at potatochowder.com wrote:
>     for (index, value) in enumerate(this_list):
>         this_list[index] = 2 * value
>
> Or:
>
>     for index in range(len(this_list)):
>         this_list[index] *= 2
>
> (But I tend to avoid that, though, because I can never remember exactly
> which mutations work inside a loop and which ones don't (or does
> enumerate remove some or all of those restrictions?).  Which feeds right
> into what you said about being comfortable with certain languages or
> programming styles.)

Since you are not using an iterator of the list, changing it shouldn't
cause any problems. You loop (for its control) looks at the loop once,
before it starts, so as long as you don't delete any elements (which
would cause the index to go to high) you can't have an issue mutating
the list.

-- 
Richard Damon



More information about the Python-list mailing list