Write a python program for replace negative numbers
n=int(input("Enter number of integers to input: "))
arr=[]
print("Input the integers:")
for i in range(n):
x=int(input())
arr.append(x)
print("Orginal integers: ",arr)
n2=int(input("Enter a number to replace negative numbers with: "))
arr2=[]
for i in arr:
if i<0:
i=n2
arr2.append(i)
print("Integers after replacement: ",arr2)
Comments
Leave a comment