Signed up recently but had issues with the confirmation email?
Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.
Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.
301.15 File Handling Techniques
Practise exam questionsFile Handling Techniques — Note 2 of 4
Read lines or whole file.
You can read a whole file at once with .read(), get a list of lines with .readlines(), or loop through line by line with a for loop. Each line includes a newline character.
.read() returns the entire file as one string.readlines() returns a list of linesfor line in f: loops one line at a time.strip() to remove trailing newline from each linewith open("names.txt", "r") as f:
for line in f:
name = line.strip()
print("Hello, " + name)Back to File Handling Techniques
Specification notes for programming are in Paper 2.