Reputation: 9
c=b.readlines()
print(len(c))
print(len(b.readlines()))
this is what I got: 2 0
Why are these two results different?
Upvotes: 0
Views: 45
Reputation: 234695
readlines()
is a function with a side-effect: it is clearly consuming data from b
.
So a second invocation may well give you a different result.
Upvotes: 0
Reputation: 9354
because you've already read the lines from b and it has nothing left to return
Upvotes: 2