Practice
Append a Visitor to the Log
MEDIUMFile Handling8 marks
File I/O question —
visitors.txt is pre-loaded for you during grading.The file visitors.txt already has some names, one per line. Read one new name, append it to the file, then read the whole file back and output every name.
Input: One name. Output: All names in the file after appending, one per line.
Example:
Input: Chen
Output: Ali
Ben
Chen
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Append a third name
visitors.txt
Ali Ben
Inputs: Chen
Expected: Ali
Ben
Chen
Test 2: Append to a single existing name
visitors.txt
Maya
Inputs: Zara
Expected: Maya
Zara