Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ADI_Sainandan_Ex1.py #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ADI_list = [10, 20, 30, 40]

# check if the list is iterable or not
# use dir() function. dir() will list all the function that the object has

# Iterables will implement __iter__() function
# But Iterators will implement both __iter__() and __next__() function
# So all iterators are iterables but not all iterables are iterators
print(dir(ADI_list))

ADIiter = iter(ADI_list)

try:
while True:
item = next(ADIiter)
print(item)
except StopIteration:
print('Stop!')