Re: [Tutor] string reversal using [::-1]

2017-06-10 Thread Alan Gauld via Tutor
On 10/06/17 17:39, Vikas YADAV wrote: > Question: Why does "123"[::-1] result in "321"? > > MY thinking is [::-1] is same as [0:3:-1], that the empty places defaults to > start and end index of the string object. Did you try that? You may be surprised. The wonderful thing about the >>> prompt is

Re: [Tutor] Python - help with something most essential

2017-06-10 Thread Japhy Bartlett
It's really awkward the way you're using Counter here... you're making new instances in every lambda (which is not great for memory usage), and then not actually using the Counter functionality: return sum(1 for _ in filter(lambda x: Counter(word) == Counter(x.strip()), fileContent)) (the

[Tutor] string reversal using [::-1]

2017-06-10 Thread Vikas YADAV
Question: Why does "123"[::-1] result in "321"? MY thinking is [::-1] is same as [0:3:-1], that the empty places defaults to start and end index of the string object. So, if we start from 0 index and decrement index by 1 till we reach 3, how many index we should get? I think we should get

Re: [Tutor] Huge list comprehension

2017-06-10 Thread Alan Gauld via Tutor
On 10/06/17 08:35, Abdur-Rahmaan Janhangeer wrote: > take a look at numpy It seems he already has, np.array is in his code. It's just the imports that are missing I suspect. > and don't necessarily give us the whole code. it becomes too long without > purpose Yes although in this case it does

Re: [Tutor] Huge list comprehension

2017-06-10 Thread Abdur-Rahmaan Janhangeer
take a look at numpy and don't necessarily give us the whole code. it becomes too long without purpose Abdur-Rahmaan Janhangeer, Mauritius abdurrahmaanjanhangeer.wordpress.com On 6 Jun 2017 03:26, "syed zaidi" wrote: hi, I would appreciate if you can help me