Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Develop code

EasyMediumHard
123456789101112131415161718192021222324252627
Question 21

Products.txt contains a list of product codes.

Open Q03a in the code editor.

Write a program to implement these requirements.

The code must:

  • read each product code from Products.txt
  • check each product code to ensure it contains a hyphen (-)
  • write any product codes that do not contain a hyphen to a Flagged.txt file

You must use the structure given in the file Q03a to complete the program.

# Q03a - Skeleton Code
infile = open("Products.txt", "r")
outfile = open("Flagged.txt", "w")

# Your code goes here

infile.close()
outfile.close()

Do not add further functionality.

[6]

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code