Python and Ruby differ significantly when it comes to the for loop. Python allows objects to dictate how the for loop operates, while Ruby treats for loop as a method of the Object, with the caller passing the loop’s body for processing. Python emphasizes conformity to language conventions for data processing, while Ruby empowers objects to control how they are processed. Python suggests a structured approach to data processing, while Ruby prioritizes expressiveness and object-oriented programming. Python resembles C-based OOP, while Ruby places object-orientation at the core. Ruby encourages developers to build APIs and DSLs based on domain modeling, making it a preferred choice for certain applications.
https://softwaredoug.com/blog/2021/11/12/ruby-vs-python-for-loop.html