(Jul-18-2018, 12:11 AM)braankoo Wrote: Could it be done better?yes. it works, but is heavily influenced by your experience with other languages.
for example we don't use indexes to iterate over elements in a sequence. We reference the elements. And use enumerate if the index is needed too. So something more pythonic would be
def is_even(sequence): my_count = 0 for i, num in enumerate(sequence, start=1): my_count += sum(num>num2 for num2 in sequence[i:]) return not my_count % 2
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs