Jan-30-2019, 04:47 PM
(Jan-30-2019, 04:39 PM)perfringo Wrote: You created empty list. Therefore index is out of range:
>>> luck = list() >>> len(luck) 0 >>> luck[0] /..../ IndexError: list index out of rangeYou should use append.
You also ask two times for input for both a and b.
One way of writing this code:
>>> a = int(input("Give number a: ")) >>> b = int(input("Give number b: ")) >>> luck = list() for i in range(b): ... luck.append(a**b)Of course, if task is [a^0,a^1,a^2,...,a^b] then one should append (a**i)
thanks but it's not working either
what i want is to print the follow :
example a=2 b=4
should print [2^0,2^1,2^2,2^3,2^4] which is [1,2,4,8,16]