How do I do exponentiation in python? [duplicate]

^ is the xor operator.

** is exponentiation.

2**3 = 8


You can also use the math library. For example:

import math
x = math.pow(2,3) # x = 2 to the power of 3