gh-36140: python-style loops in `partn_ref.data_structures` (partial) + some pep8
This converts some loops to the python style.
Plus a few pep8 details fixed
### :memo: Checklist
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
URL: https://github.com/sagemath/sage/pull/36140
Reported by: Frédéric Chapoton
Reviewer(s):
Committer
Release Manager