~ The simplest way to read from a file in Python

Reading from a file in python - this is where it gets interesting!

Challenge - Read from a text file in Python

Read the task instructions that are included in the comments in the code, and then get started!

You can either edit and code online in repl.it (click on the link on the right which says EDIT on repl.it. Alternatively, you can simply cut and paste the below into your own python file

Solve the challenge on repl.it


""" ==============TASK
1. Create a new file called fakefacebook.txt
2. In it store the following data for 3 individuals

          username, password, emailaddress,    no.of.friends
    e.g.  marvR     pass123   [email protected]   400

3. Print the results of the file to the screen

import csv

#1. Open the File, Read it into a list, and Print Contents 

with open("studentinfo.txt",newline="") as f:
  for row in reader:

File Contents

filename: studentinfo.txt


Code your solution here

Systems Life Cycle (in a nutshell): Analyse - Design - Create - Test - Evaluate. Designing something or writing out some pseudocode before you actually write code is always a good idea! Get in to the habit of doing so! You can draw your flowchart here and screenshot it.

A sample flow chart (design) for this particular challenge could look like:

Flowchart: Python program to get the Fibonacci series between 0 to 50
Each challenge section below provides an online drawing tool where you can dynamically create flowcharts. Screenshot them into your presentation for submission.

Solutions & Answers

Answers /Solutions in the "members area" drive under: "Solve and Learn >>SOLUTIONS"

Testing Table

You may want to read a little about Testing first. A teacher may go through some examples with you. Feel free to fill in the test table here, and screenshot it in to your powerpoint. Testing is absolutely essential once you have created a program!
Test No. Description Test Data(input) Expected Outcome Actual Outcome Further Action?
Coming soon!