I know this is a topic that there are already several threads for. I've reviewed them and understand what this error means, but for some reason cannot get it to work for my code.
I'm trying to code a simple Python function that takes a list of integers as input and outputs the integers in the list that are exactly twice the amount of the previous integer in the list. Here is the code I have so far:
def doubles(lst):
i = -1
for num in lst:
if num == num[i + 1] / 2:
print(num)
Now I know the issue is that it is trying to print this integer as a string. I have tried editing the codes last line to say print(str(num)) and that does not work, nor does changing my if statement in line 4. Any assistance would be greatly appreciated!