lundi 9 mai 2022

How can I print the lines from the text file next to random generated numbers

The text file is "ics2o.txt" and I don't know how to print numbers next to the lines

import random 
print ("----------------------------------------------------------")
print ("Student Name Student Mark")
print ("----------------------------------------------------------")

f = open("ics2o.txt")
for line in f:
  x = len(f.readlines())
  for i in range (x):
    contents = f.read()
    print(str(contents) + str(random.randint(75,100)))



Aucun commentaire:

Enregistrer un commentaire