Sum-Positive

Wed 12 November 2025
def sum_positives(lst):
    positive_sum = sum(x for x in lst if x > 0)
    print("Sum of Positive Numbers:", positive_sum)

# Example usage
sum_positives([-1, 2, 3, -4, 5])
Sum of Positive Numbers: 10
def shift_list(lst, k):
    k = k % len(lst)  # Handle shifts larger than list length
    shifted = lst[-k:] + lst[:-k]
    print("Shifted List:", shifted)

# Example usage
shift_list([1, 2, 3, 4, 5], 2)
shift_list([1, 2, 3, 4, 5], 7)
Shifted List: [4, 5, 1, 2, 3]
Shifted List: [4, 5, 1, 2, 3]


Score: 0

Category: python-basics