Coding basics · 9 of 20
Power without **
Return base raised to exp (exp is 0 or more), using a loop instead of ** or pow().
What you need
When the loop counter isn't needed, name it _. range(k) runs k times (0 to k - 1).
for _ in range(3):
print("hi") # prints hi three timesExamples
Input base = 2, exp = 10
Output 1024
Input base = 5, exp = 0
Output 1
Input base = -3, exp = 3
Output -27