Answer to Question #265888 in Python for Lovely

Question #265888

Write a python program for replace negative numbers


1
Expert's answer
2021-11-15T00:23:10-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS