The following line of code:
for line in open('text.txt', 'rt'):
- is invalid because open returns a non-iterable object
- is invalid because open returns nothing
- is valid because open returns an iterable object
- may be valid if line is a list
Explanation: The open() method returns an iterable object, which can be used to iterate through all the file’s lines inside a for loop.
More Questions: Python Essentials 2 (PE2) Course Final Test
Please login or Register to submit your answer