Re: Enumerate - int object not subscriptable

2019-08-21 Thread Peter Otten
Sayth Renshaw wrote: > def output_data(s): > serie = fibo(input_length) > x = [] > y = [] > > for num1, num2 in pairwise(serie): > y.append( num2 / num1) It looks like y contains unique values. In that case replace > for item in y: > x.append(y.index(item

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Sayth Renshaw
On Wednesday, 21 August 2019 03:16:01 UTC+10, Ian wrote: > Or use the "pairwise" recipe from the itertools docs: > > from itertools import tee > > def pairwise(iterable): > "s -> (s0,s1), (s1,s2), (s2, s3), ..." > a, b = tee(iterable) > next(b, None) > return zip(a, b) > > for n

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Ian Kelly
Or use the "pairwise" recipe from the itertools docs: from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return zip(a, b) for num1, num2 in pairwise(a): print(num1, num2) On Tue, Aug 20, 2019 at 7:42 AM

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Cousin Stanley
Sayth Renshaw wrote: > I want to do basic math with a list. > > a = [1, 2, 3, 4, 5, 6, 7, 8] > > for idx, num in enumerate(a): > print(idx, num) > > This works, but say I want to print the item value > at the next index as well as the current. > > for idx, num in enumerate(a): > > print(n

Re: Enumerate - int object not subscriptable

2019-08-20 Thread BlindAnagram
On 20/08/2019 13:00, Sayth Renshaw wrote: > Hi > > I want to do basic math with a list. > > > for idx, num in enumerate(a): > print(idx, num) > > This works, but say I want to print the item value at the next index as well > as the current. > > for idx, num in enumerate(a): > print(

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Frank Millman
On 2019-08-20 2:00 PM, Sayth Renshaw wrote: Hi I want to do basic math with a list. a = [1, 2, 3, 4, 5, 6, 7, 8] for idx, num in enumerate(a): print(idx, num) This works, but say I want to print the item value at the next index as well as the current. for idx, num in enumerate(a):