Given a list of integers, write a program to print the sum of all prime numbers in the list of integers.
Note: one is neither prime nor composite number
Using the pass statement
entered_list = input("Enter a list of numbers separated by spaces: ").split()
num_list = list(map(int, entered_list))
prime_number = []
for i in num_list:
for j in range(2, i):
if i % j == 0:
break
else:
prime_number.append(i)
for i in prime_number:
if i == 1:
prime_number.remove(i)
else:
pass
if len(prime_number) > 0:
print(sum(prime_number))
else:
print("There are no prime numbers in this list")
Comments
Leave a comment