Extract element from a set without removing it

0 votes
How can I extract an element from a python set, while leaving the set unchanged?
Jun 7, 2018 in Python by nightshade
• 870 points
8 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Use iter():

element = next(iter(set_1))
answered Jun 7, 2018 by Hamartia's Mask
• 1,580 points

Related Questions In Python

0 votes
1 answer

Python - Use unique element from a set

The best way to achieve this by ...READ MORE

answered Mar 27 in Python by Mugdha
• 500 points
34 views
0 votes
1 answer

How to extract values from a string or a sequence?

you could use the statements like name[index value ...READ MORE

answered Mar 6 in Python by Waseem
• 1,990 points
14 views
0 votes
1 answer
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,710 points
38 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
20 views
+4 votes
6 answers
0 votes
1 answer

Deleting a list element by value

Use the remove() function: >>> p = [1, ...READ MORE

answered May 11, 2018 in Python by Hamartia's Mask
• 1,580 points
9 views
0 votes
2 answers

Delete a character from pythons string

If you want to remove the 'J' ...READ MORE

answered Jun 12, 2018 in Python by anonymous
24 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.