On 1/18/2017, Peter Otten wrote:
> with partite.txt looking like this
>
> > 74' Kessie'
> > 90' + 4' D'alessandro
> > 51' Mchedlidze
> > 54' Banega
> > 56' Icardi
> > 65' Icardi
> > 14' Sau
>
>
> Assuming you want to perform a numerical sort on the numbers before the '
> you can just apply sor
with open('partite.txt', 'r') as r:
for line in sorted(r):
print(line, end='')
2017-01-18 15:38 GMT-05:00 Smith :
> On 18/01/2017 21:34, MRAB wrote:
>
>> If you're wondering about the blank lines, it's because the lines end
>> with '\n', which starts a new line, and the print function
On 18/01/2017 21:34, MRAB wrote:
If you're wondering about the blank lines, it's because the lines end
with '\n', which starts a new line, and the print function also starts a
new line after printing the string.
Try stripping the '\n' off the end of the line read in with the .rstrip
method.
Th
On 18/01/2017 21:21, Grant Edwards wrote:
I would have done better by posting the actual code instead of a blind
link that may point to Dog-knows-what...
sorry :-(
--
https://mail.python.org/mailman/listinfo/python-list
On 18/01/2017 21:20, Peter Otten wrote:
with open("partite.txt") as f:
by_number = sorted(f, key=lambda line: int(line.partition("'")[0]))
print("".join(by_number))
Great!!! :-)
--
https://mail.python.org/mailman/listinfo/python-list
On 2017-01-18 19:51, Smith wrote:
Hi all,
could you do better?
Thank you in advance
link code:
https://repl.it/FMin/8
If you're wondering about the blank lines, it's because the lines end
with '\n', which starts a new line, and the print function also starts a
new line after printing the stri
On 2017-01-18, Smith wrote:
> could you do better?
Yes.
> link code:
> https://repl.it/FMin/8
I would have done better by posting the actual code instead of a blind
link that may point to Dog-knows-what...
--
Grant Edwards grant.b.edwardsYow! I had pancake makeup
Smith wrote:
> Hi all,
> could you do better?
> Thank you in advance
>
> link code:
> https://repl.it/FMin/8
Don't make it unnecessarily hard to find your code -- as long as it's small
you can include it into your mail
Given
> with open('partite.txt', 'r') as f:
> splitted = [(int(line.spl
Hi all,
could you do better?
Thank you in advance
link code:
https://repl.it/FMin/8
--
https://mail.python.org/mailman/listinfo/python-list