Here is a more simplified approach:
question = input("Enter an input like x^3, x^25 etc...: ")
n = question[question.index('^')+1:]
power = str(int(n) - 1)
derivative = n + 'x' + '^' + power
print(derivative)
Output:
Enter an input like x^3, x^25 etc...: x^25
25x^24