// This is equivalent to
for i in range(1,3):
print(i, end=' ')
// Any function that includes "yield" is called a generator and it works like range(), so that you can use them both in a loop like "for", but there are differences, e.g. you can use a generator inside next() but you cannot use range() inside next() because range() is stateless
With f(2), n = 2, so the range will be range(1, {2+1}) or range(1,3). The iterations of i would then be 1 and then 2 with yield sending each iteration back to "for i in f(2)". Hope this explains it.
upvoted 3 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
CC_DC
1 year, 4 months agomacxsz
2 years, 7 months agoNorasit
2 years, 7 months agorocky48
2 years, 8 months agorocky48
2 years, 8 months agoBacky
2 years, 9 months agoruydrigo
2 years, 12 months agotechdawgs
2 years, 11 months ago