LH10 added iterator

This commit is contained in:
K 2024-02-17 18:39:00 +05:30
parent 27069b283c
commit c33f887e27
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

View File

@ -54,6 +54,12 @@ def intersection(setA, setB):
intersectionSet.append(i)
print(f"Intersection is:\t{intersectionSet}")
def iterator(setA):
a = iter(setA)
for i in range(0,len(setA)-1):
print(next(a),"->",end=' ')
print(next(a))
def union(setA, setB):
# Function to perform union of two sets
unionSet = []
@ -136,7 +142,14 @@ def main():
else:
print("\nPlease choose a valid option.\n")
elif (optn == 5):
print("\nIMPLEMENTATION PENDING\n")
setSel = int(input("Which set to operate on?\n1. Set one\n2. Set two\nSet 1/2:\t"))
a = None
if (setSel == 1):
iterator(setOne)
elif (setSel == 2):
iterator(setTwo)
else:
print("\nPlease choose a valid option.\n")
elif (optn == 6):
intersection(setOne, setTwo)
elif (optn == 7):