-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1105_generator Function.py
More file actions
64 lines (54 loc) · 1.05 KB
/
Copy path1105_generator Function.py
File metadata and controls
64 lines (54 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#def main():
#print("starting main")
#for i in inclusive_range(0, 5, 1):
#print("function called, printing the i ")
#print(i)
#
#def inclusive_range(start, stop, step):
#print("in the function after the call")
#i = start
#while i <= stop:
#print("yielding i")
#yield i
#print("yielded i, increasing the counter")
#i+=step
#print("increased counter")
#
#main()
####################################
#def main():
#for i in inclusive_range(0, 5, 1):
#print(i)
#
#def inclusive_range(start, stop, step):
#i = start
#while i <= stop:
#yield i
#i+=step
#
#main()
####################################
def main():
for i in inc_range(2):
print(i)
def inc_range(*args):
lenargs = len(args)
if lenargs < 1:
raise TypeError('no argument provided')
print("atleast one args is expected")
elif lenargs == 1:
stop = args[0]
start = 0
step = 1
elif lenargs == 2:
(start, stop) = args
step = 1
elif lenargs == 3:
(start, stop, step) = args
else:
printttt("too many args")
i = start
while i <= stop:
yield i
i += step
main()