-
I'm not a python dev and I don't really know what I'm doing but here are my thoughts.
Long nested loops like in your main function get really hard to follow very quickly. Ideally you never want to go deeper than 1 loop. Try and keep your variable names meaningful too, 'x' isn't a great name. In line 26-27 you're catering for a case where nothing happens, so you don't need to cover it.
Attached my small refactor
1 Attachment
learning functions.
can someone please run this and let me know if I'm being long winded / over complicating things or if it is OK?
I'm sure I've already got some bad habits so would really appreciate some constructive feedback!