Python - Use unique element from a set

0 votes
I have a scenario where I have a sequence of unique values. I need use these unique values one at a time and the value should be selected randomly. Also, the value should not be available for use again. Which function/functions will be useful?
Mar 26, 2019 in Python by Mishti
• 480 points
494 views

1 answer to this question.

0 votes

The best way to achieve this by using the pop function. Assuming the unique values are available in a set, say s1={2,5,7,9}, then the function results as shown below-

Hope this helps.

answered Mar 27, 2019 by Mugdha
• 600 points

Related Questions In Python

0 votes
1 answer

Extract element from a set without removing it

Use iter(): element = next(iter(set_1)) READ MORE

answered Jun 7, 2018 in Python by Hamartia's Mask
• 1,580 points
987 views
0 votes
1 answer

How to use read a WSDL file from the file system using Python suds?

Hi, good question. It is a very simple ...READ MORE

answered Jan 21, 2019 in Python by Nymeria
• 3,560 points
7,715 views
0 votes
1 answer
0 votes
4 answers

How do I remove an element from a list by index in Python?

Delete the List and its element: We have ...READ MORE

answered Jun 7, 2020 in Python by sahil
• 580 points
276,786 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
2,039 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,067 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,487 views
0 votes
1 answer

Exclusive values from two Sets in Python

There is a direct function available to ...READ MORE

answered Mar 27, 2019 in Python by Mugdha
• 600 points
992 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP