Computer Science, asked by thedark7, 1 month ago

write a python program to remove all numbers in a list

Answers

Answered by anindyaadhikari13
1

Answer:

The given program is written in Python.

n=int(input("How many elements? "))

a=[]

print("Enter them...")

for i in range(n):

     a.append(int(input(">> ")))

print("Given list:",a)

a.clear()

print("Modified list:",a)

Explanation:

  • To remove all the items in a list, the clear() method is used.
  • Using this function, the problem is solved.

Variable Description:

\dag\ \boxed{\begin{array}{c|c|c}\tt\underline{{N}ame}:&\tt \underline{Type}:&\tt\underline{Function}:\\ \sf n&\sf int&\sf Number\:of\:elements\:for\:list.\\ \sf a&\sf list&\sf Stores\:the\:elements.\end{array}}

Refer to the attachment.

•••♪

Attachments:
Similar questions