Problem Statement:
In the Sum of non-primes in Python, we are given a list of numbers, we need to find the sum of non-prime numbers in the given list.
Code for Sum of non-primes in Python:
# declaring list of numbers
numbers = [2, 35, 5634, 12, 354, 87, 34, 123, 43, 67, 34, 98, 13, 11]
# declaring empty list
non_primes =[]
# declaring for loop
for i in numbers:
flag=1
# checking whether a number is prime or not
for j in range(2, i//2+1):
if i%j==0:
flag=0
break
# storing non prime numbers only
if flag==0:
non_primes.append(i)
# printing sum of non primes
print(sum(non_primes))
Output:

Explanation:
We simply stored non-prime numbers in an empty list by filtering the original list containing all numbers. At last, we simply printed the sum with the help of sum() method(a built-in method for list) in Python. Please comment for any queries
Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Composite Number in Python
- Greatest Among Four Numbers in Python
- Reverse the sentence in Python
- Denominations in Python
- Min and max values in an array in JavaScript
- Keyboard events in JavaScript
- Reaching Ground Floor in Python
- Number of Moves in Python
- Starks Adventure in Python
- Neutralization in Python | Assignment Expert
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- First Place in Python
- Triples with Properties in Python
- Nested list Indexing Python
- Team Points in Python
- Two words combination in Python
- ID Card in Python
- Cipher with a key in Python | Assignment Expert
- Multiple of 5 in Python
- Sandglass Star in Python
- Multiple of 3 in Python | Assignment Expert
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Sum of List Elements in Python
- All possible subsets in Python
- Names and Nicknames in Python
- Pager in Python | Assignment Expert
- Validation in Python
- Tournament 2 in Python
- Polynomial in Python

