I am coding an nth term of a mathematical sequence generator. I'm just experimenting with the first seven terms for now.
The user enters 1,2,3,4,5,6 and 7 (or any other consecutive values) into the sequence, then the program should multiply the 1st, then every other term entered by 8 (so in this case the 1st, 3rd, 5th and 7th numbers entered).
It should also multiply the 2nd then every other term entered by 2 (so in this case the 2nd, 4th and 6th numbers entered).
Afterwards, I want it to add everything together. Here is what I tried to do:
x = [0,0,0,0,0,0,0]
for n in range (0,7):
x[n] = int(input("Input the digits of the sequence one by one:"))
if x[n] == x[0] or x[2] or x[4] or x[6]:
x[n] == x[n]*8
elif x[n] == x[1] or x[3] or x[5]:
x[n] == x[n]*2
else:
break
finalnumber = x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]
print(finalnumber)
I inputted 1,2,3,4,5,6 and 7 and calculated myself that the finalnumber should be 152, however this program for some reason printed 28.
Please tell me what I have done wrong.
I am using Python 3.6.