In this lab you will use files that contain lists of names p
Solution
#The python program that reads three text files using loadFile method
#and generates a random indexes of titleList, nameList and descriptor list
#and print to console.
import random
def main():
titleList=loadFile(\'title.txt\')
nameList=loadFile(\'names.txt\')
desciptorList=loadFile(\'descriptor.txt\')
#generate four random numbers from the lists
r1=random.randint(0,len(titleList)-1)
r2=random.randint(0,len(nameList)-1)
r3=random.randint(0,len(nameList)-1)
r4=random.randint(0,len(desciptorList)-1)
#prnt to console
print(\'%s%s%s%s\'%(titleList[r1],nameList[r2],nameList[r2],desciptorList[r4]))
#Method that reads given text file
def loadFile(filename):
fopen=open(filename,\"r\")
lines=fopen.readlines()
return lines
main()
----------------------------------------------------------------------------------------------------
Note :Use your own input text files and run the program in python 3
----------------------------------------------------------------------------------------------------
