Python: Calculating exponents of a base
<p>I am new to python and trying to figure out how to get an exponent to times a certain time of the base, ex. 5<sup>4</sup>, without using the exponent operator, **.</p>

<p>For this, I am trying to implement the use of the for loop but the thing is I cannot figure out how to achieve this with a loop.</p>

<p>This is what I got so far.</p>

<pre><code>base = int(input("ENTER NUMBER: "))
exponent = int(input("ENTER EXPONENT: "))

for item_name in things_with_item:
    if exponent == 0:
        print("something")
    elif exponent &gt; 0:
        print("something")
    else:
        print("ERROR. TRY AGAIN")
</code></pre>

<p>What I am stuck with is what variables I should use to replace "item_name" and "things_with_items" and also how to calculate the answer of 5<sup>4</sup> like 5 * 5 * 5 * 5. Do I need to make a variable for the calculation of 5<sup>4</sup> or would the loop do that for me?</p>

<p>I really don't know where to start, if you guys could provide me with some hints, that would be wonderful.</p>

<p>Thank you</p>

<p>Try this code:</p>

<pre><code>base = int(input("ENTER NUMBER: "))
exponent = int(input("ENTER EXPONENT: "))
no = base * base
for item_name in range(exponent):
    if exponent == 0:
        print(1)
    elif exponent &gt; 0:
        no += base * exponent * base * item_name
        if no == base ** exponent:
            print(no)
    else:
        print("ERROR. TRY AGAIN")
</code></pre>

python python-3.x