Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Finding if 2 consecutive numbers in a list have a sum equal to a given number

def sum_finder(num_list, sum):

    for num in num_list:
        
        if((num_list.index(num) + 1) >= len(num_list)):
            return False
        
        if((num + num_list[num_list.index(num) + 1]) == sum):
            print(num, (num_list[num_list.index(num) + 1]))
            return True
Comment

PREVIOUS NEXT
Code Example
Python :: na.fill pyspark 
Python :: matplotlib colormap transparent white to black 
Python :: python open file location 
Python :: merge two arrays python 
Python :: How To Remove Elements From a Set using pop() function in python 
Python :: where is python installed windows 
Python :: django-tool-bar 
Python :: pandas rename columns whitespace with underscore 
Python :: is plaindrome python 
Python :: pandas convert column to title case 
Python :: Reversing Ints 
Python :: ImportError: sys.meta_path is None, Python is likely shutting down 
Python :: how to play audio in python using pygame 
Python :: airflow schedule interval timezone 
Python :: how to extract values from a dictionary 
Python :: multiprocessing while applying a function in pandas 
Python :: size of int in python 
Python :: django run manage.py from python 
Python :: basic flask api 
Python :: pydrive download by url 
Python :: string format method python 
Python :: how to open annaconda 
Python :: python check if false in dict 
Python :: Convert Int to String Using format() method 
Python :: null in python 
Python :: sort function in pandas dataframe to sort specific properties 
Python :: drf model methods serializer 
Python :: use latest file on aws s3 bucket python 
Python :: django add queury parameters to reverse 
Python :: append and extend in python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =