Computer Science, asked by singhamrita27789, 4 months ago

write.a program in python to create a list by accepting 10 values from user,including two negative values and delete all the negative values and display the resultant list.Any python expert please answer this and help me out!!​

Answers

Answered by mayabk
1

Answer:

The code is

import sys

print("*"*50)

print("Enter two negative values")

print("*"*50)

a=int(input("Enter the first  negative number:-"))

b=int(input("Enter the second negative number:-"))

c=int(input("Enter the first number:-"))

d=int(input("Enter the second number:-"))

e=int(input("Enter the third number:-"))

f=int(input("Enter the fourth number:-"))

g=int(input("Enter the fifth number:-"))

h=int(input("Enter the sixth number:-"))

i=int(input("Enter the seventh number:-"))

j=int(input("Enter the eighth number:-"))

print("*"*50)

if a>0:

   print("Enter two negative numbers")

   print("*"*50)

   sys.exit()

if b>0:

   print("Enter two negative numbers")

   print("*"*50)

   sys.exit()

if c<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

if d<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

if e<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

if f<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

if g<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

if h<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

if i<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

if j<0:

   print("Enter only two negative numbers")

   print("*"*50)

   sys.exit()

else:

   print("The discarded numbers:-",a,",",b)

   print("The list of numbers:-\t(1)",c)

   print("\t\t\t(2)",d)

   print("\t\t\t(3)",e)

   print("\t\t\t(4)",f)

   print("\t\t\t(5)",g)

   print("\t\t\t(6)",h)

   print("\t\t\t(7)",i)

   print("\t\t\t(8)",j)

   print("*"*50)

Explanation:

Similar questions