Reputation: 1
def down_detector(nums) {
nums = int(input('Enter nums: '))
for i in range(len(nums) - 1):
if nums[i]==5 and nums[i+1]==9:
return 1
if nums[i]==5:
return 1
if nums[i]==5 and nums[i]==11:
return 2
print(nums)
Upvotes: 0
Views: 65
Reputation: 256
I can't really help you with your code, because it doesn't make any sense. But I can try my best explaining you were the problems are :)
Upvotes: 1
Reputation: 349
I'm not quite sure what your trying to do, but this is my best guess:
The main problem with your code is you are inputting nums
as an int
, when it really is a list. To solve this problem, we can use .split() like this:
nums = input('enter numbers divided by spaces').split()
However, please do note that all the values of this list will be strings, not integers, so we do:
nums = [int(i) for i in nums]
Afterwards, your if statements should work, but as Pixelbog pointed out, your code is a bit convoluted, so you might want to fix that as well!
Upvotes: 1