All Courses

Write a program to iteration over sets

By Sde221876@gmail.com, 3 months ago
  • Bookmark
0

Write a program to iteration over sets

Python
Sets
Iteration
2 Answers
0
Hitendradixit18@gmail.com

Hint:

for i in set:

  print i

0
Goutamp777

Certainly! Here is an example of how you can iterate over a set in Python:

# define a set
my_set = {1, 2, 3, 4, 5}


# iterate over the set
for item in my_set:
  print(item)

This will output the items in the set one by one:

1
2
3
4
5


Your Answer

Webinars

Live Masterclass on : "How Machine Get Trained in Machine Learning?"

Mar 30th (7:00 PM) 516 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More