Error while doing Reverse:

Asked

Viewed 36 times

0

in Eat.txt there is the following content:

02:26:31 14:44:45 09:53:27
14:17:35 12:33:44 09:30:12

I’m reversing the order of the elements ad following way:

import sys

with open 'eat.txt as f:
    lines = f.read().strip().splitlines()

for line in lines:
    out = ' '.join(sorted(line.split(), reverse=True))
    print(out)

Exit:

14:44:45 09:53:27 02:26:31
14:17:35 12:33:44 09:30:12

Why does he just switch the first line and the second no?

  • 1

    Simple: because the second line is already ordered in reverse order. :)

1 answer

1


If you observe, the second line is already ordered inversely. So it appears that nothing happened.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.