+ 2
Can anyone help me with this simple python code?
This python code isn't working. Can anyone help me get it working? https://code.sololearn.com/cN11uDVtzc7I/?ref=app
1 Answer
+ 6
There are just a couple mistakes in your code:
First, line 5 is returning an error simply because of the order you put it in. When setting a value to a variable, you would need to put the actual variable name first with its value being second (becoming z = x + y)
Second, you're trying to append the value of z into a list which doesn't exist. Changing line 6 to fibonacci.append(z) will append the value to the correct list.
At this point, the code works fine, but to have it output the fibonacci sequence you would need to change the range to (1,100), as the variable y would be set to -1 otherwise in the first iteration, completely setting off the sequence