Python Forum
For loop + add something - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: For loop + add something (/thread-37542.html)

Pages: 1 2


RE: For loop + add something - DeaD_EyE - Jun-24-2022

(Jun-23-2022, 11:04 PM)Pedroski55 Wrote: Knowing a list is in fact an integer indexed array, the index beginning with zero, why not make use of that fact and the relationship of the length to the indexing? Simple and useful!

Often the only thing you know: This object is iterable ...

I guess you come from another language and try to apply the convention of the language you've learned to Python. We often see the results in existing libraries, which look like Java (getters/setters everywhere).

If you want to make it more difficult and unflexible, then you should use indices everywhere.
I showed you an example, where the Code breaks. Why ignoring it?