Ask Your Question

converting a set into a list?

asked 2014-02-02 07:29:49 -0600

REKHA BISWAL gravatar image

how to convert a set into a list in sage?

edit retag flag offensive close merge delete


I would have thought the current answer works, so please edit your post to a very explicit example. By the nature of sets, their is only one of each element! Or do you mean multisets, or just want partitions? Thanks!

kcrisman gravatar imagekcrisman ( 2014-02-03 03:49:06 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-02-02 08:01:57 -0600

ndomes gravatar image
S = set([1,1,2,2,2,3,4,5])
L = list(S)
print L;
type(S); type(L)
edit flag offensive delete link more


@ndomes But it keeps only one 1 in the list.But i want to write set([1,1,2,2,2,3,4,5]) in partition form.That means i want output to be the list [5,4,3,2,2,2,1,1].Could you please tell me how to do it?

REKHA BISWAL gravatar imageREKHA BISWAL ( 2014-02-02 17:43:47 -0600 )edit

by definition, a set has no duplicate entries.

Volker Braun gravatar imageVolker Braun ( 2014-02-03 09:44:42 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-02-02 07:29:49 -0600

Seen: 1,093 times

Last updated: Feb 02 '14