Scroll to see replies
textfile = open(filename,"a+") #Opens textfile as append
textfile.write("text\n") #Writes text and new line
textfile.close() #Closes textfile
In the write bit, you could write it to the textfile like "name|score"data = (["registration1", 10], ["registation2", 7], ["registation3", 8])
if not re.match("^[A-Z][A-Z]\d\d \d[A-Z][A-Z]$", postcode):
print("Postcode is non-standard")
file = open("textfile.txt","a") #Opens in append mode
file.write(string +"\n") #Write to file and create new line
file.close() #Close file
data = (["registration1", 10], ["registation2", 7], ["registation3", 8])
Now, it looks like while you are going through that list, you must check if the registration plate is standard, and write it to a file if it isn't.if not re.match("^[A-Z][A-Z]\d\d \d[A-Z][A-Z]$", postcode):
print("Postcode is non-standard"
Obviously, you'll have to adjust that for the format of a vehicle registration for yourself.file = open("textfile.txt","a" #Opens in append mode
file.write(string +"\n" #Write to file and create new line
file.close() #Close file
Last reply 1 minute ago
Interview invitation for GAP medicine course at Glasgow University in 2022Last reply 3 minutes ago
LSE politics and Economics 2023/2024Last reply 3 minutes ago
Official London School of Economics and Political Science 2024 Applicant ThreadLast reply 4 minutes ago
LSE International Social and Public Policy and Economics (LLK1) 2024 ThreadLast reply 6 minutes ago
What happens if i dont manage to find housing for second yr?- Uni of BathLast reply 6 minutes ago
Biology - myocardial infarctionLast reply 14 minutes ago
Official University of Bristol Offer Holders Thread for 2024 entryLast reply 15 minutes ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 19 minutes ago
Goldmansachs Degree Apprenticeship 2024Last reply 20 minutes ago
Is it hard to make friends in college/sixth form?Last reply 15 minutes ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 1 day ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 1 week ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]Last reply 15 minutes ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 1 day ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 1 week ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]