Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Index Power by yuzu_chimp
def index_power(ar: list[int], n: int) -> int:
# your code here
if n >= len(ar):
return -1
else:
return ar[n]**n
print("Example:")
print(index_power([1, 2, 3], 2))
# These "asserts" are used for self-checking
assert index_power([1, 2, 3, 4], 2) == 9
assert index_power([1, 3, 10, 100], 3) == 1000000
assert index_power([0, 1], 0) == 1
assert index_power([1, 2], 3) == -1
print("The mission is done! Click 'Check Solution' to earn rewards!")
June 3, 2023