I am writing a code which is supposed to print a series in the form:
x - (x^2)/2! + (x^3)/3! - (x^4)/4! ... (x^n)/n!
where x and n are input from the user end.
For now my code looks like this
x = int(input('Enter number: '))
n = int(input('Till which term? '))
#for series
for i in range(1,n+1,1):
if i == n:
print('('+str(x)+'^'+str(i)+')'+'/'+str(i)+'!')
elif i == 1:
print(str(x),end = ' - ')
else:
if i%2 != 0:
print('('+str(x)+'^'+str(i)+')'+'/'+str(i)+'!',end = ' - ')
else:
print('('+str(x)+'^'+str(i)+')'+'/'+str(i)+'!',end = ' + ')
but the output is:
================= RESTART: E:/Python/Files/special series 4.py =================
Enter number: 3
Till which term? 6
3 - (3^2)/2! + (3^3)/3! - (3^4)/4! + (3^5)/5! - (3^6)/6!
is there any function to write in superscript to avoid the arrow-head sign?