Whenever my algorithm inputs a two digit number into my list such as 10, it inputs it as a = [1, 0]
and not a = [10]
How can I stop this?
My program is meant to take the user's number and generate x amount of generations of the Fibonacci sequence. (1, 1, 2, 3, 5, 8...)
Heres my code:
def get_integar(help_text):
global num
num = int(input(help_text))
a = []
get_integar("Enter number of generations: ")
j = 0
x = 0
sum_jx = 0
for i in range(num):
if j == 0 and x == 0:
j = 1
a.extend(str(j))
x = 1
a.extend(str(x))
else:
sum_jx = j + x
a.extend(str(sum_jx))
x = j
j = sum_jx
i = i + 1
print(a)
for example here is one outcome with 7 generations:
Enter number of generations: 7
['1', '1', '2', '3', '5', '8', '1', '3', '2', '1']
it should be
['1', '1', '2', '3', '5', '8', '13', '21']