Answers for "python sum 3 values"

2

how to sum numbers of a list in python without sum

please subscribe my channel - https://bit.ly/2Me2CfB

# METHOD 1 (without using the sum function) :

def list_sum(list_name): 
    value = 0 
    for values in list_name:
        value += values
        print(value)
        
        
# -------------------------------------------


# METHOD 2 (using the sum function) :

p = [1,5,3,4,6,7]
p_sum = sum(p)
Posted by: Guest on July-09-2021
0

sum of multiples of 3 or 5 python

total = []

for num in range(0,1001):
    if (num % 3 == 0) or (num % 5 == 0):
        total.append(num)
        
print(sum(total))
Posted by: Guest on August-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language