Programming Examples
Python program that has a list of positive and negative numbers Create a new tuple that has only positive numbers from the list
Write a program that has a list of positive and negative numbers. Create a new tuple that has only positive numbers from the list
Solution
Numbers = (5, -8, 6, 8, -4, 3, 1)
Positive = ( )
for i in Numbers:
if i > 0:
Positive += (i, )
print("Positive Numbers: ", Positive)
Output
Positive Numbers: (5, 6, 8, 3, 1)