Computer Science, asked by alkavicky2, 3 months ago

write a code in python to accept the list mylist=[] as parameter and print the list in descending order​

Answers

Answered by allysia
1

Answer:

It goes like:

\\\tt n=int(inp ut("Enter\ the\ list\ length: ")) \\\tt lis=[] \\\tt for\ i\ in\ range(0,n): \\\tt {\qquad a=int(in put("Enter list element: ")) } \\\tt  {\qquad lis.append(a) } \\\tt   \\\tt for\ j\ in\ range(0, len(lis)): \\\tt {\qquad for\ \ i\ in\ range(1,len(lis)): } \\\tt  {\qquad {\qquad  if\ lis[i-1]<lis[i]: }} \\\tt  {\qquad {\qquad {\qquad lis[i-1],lis[i]=lis[i],lis[i-1] }}} \\\tt  {\qquad {\qquad else: }} \\\tt    {\qquad  {\qquad{\qquad pass }}} \\\tt  print(lis)

Consider the attachment in case you're having trouble understanding the latex.

Attachments:
Similar questions