Answered You can hire a professional tutor to get the answer.

QUESTION

Hi There I just created a Program of File and List. When I try to run it Shows me an error of indentation. I check the program twice but i can't see...

Hi There I just created a Program of File and List. When I try to run it Shows me an error of indentation. I check the program twice but i can't see Nothing wrong in it. Can someone Help me out with this.

Also, I need to draw an NS Diagram. I have No Idea about NS Diagram. 

Below are my codes:

import string

#check validation fro rego number

def checkValidation(regoNum):

#check rego number with if condition

if(len(regoNum) == 6):

print(regoNum + ": It IS a valid rego number")

else:

print(regoNum + ": It IS NOT a valid rego number")

#read input file

def readInputFile():

infileName = input('Enter file name: ')

print("");

try:

# open the file for reading

infile = open(infileName, 'r')

except (FileNotFoundError, IOError):

print("Note: File not found.")

return

print("Note: File found.")

# read the file a line at a time and display

for line in infile:

#split by space

regoNum = line.split(' ', 1)[0]

#split by tab

regoNum = regoNum.split('t', 1)[0]

#split by new line

regoNum = regoNum.split('n', 1)[0]

if(len(regoNum) != 0):

checkValidation(regoNum)

#main() method where execution begin

def main():

#call readInputFile() method for read the file

readInputFile()

main ()

A1B2C3 Peter McDonald

MYREGO Mary Smith

ITC415 Katy Perry

JO12

HELLO1 Iam Botham

HE11O1 Peter Adams

ABC123 Nelson Mandela

HI5HI5 Kevin Jones

HELLO

ABC123 John White

ITC106 Alan Parker

TT63YY Anil Patel

ALAN13 Brian Lara

MYCARNO Smith Wills

Susan Sugar

87MYNO Margaret Bongs

import string

#check validation fro rego number

def checkValidation(regoNum):

#check rego number with if condition

if(len(regoNum) == 6):

print(regoNum + ": It IS a valid rego number")

else:

print(regoNum + ": It IS NOT a valid rego number")

#read input file

def readInputFile():

infileName = input('Enter file name: ')

print("");

try:

# open the file for reading

infile = open(infileName, 'r')

except (FileNotFoundError, IOError):

print("Note: File not found.")

return

print("Note: File found.")

# read the file a line at a time and display

for line in infile:

#split by space

regoNum = line.split(' ', 1)[0]

#split by tab

regoNum = regoNum.split('t', 1)[0]

#split by new line

regoNum = regoNum.split('n', 1)[0]

if(len(regoNum) != 0):

checkValidation(regoNum)

#main() method where execution begin

def main():

#call readInputFile() method for read the file

readInputFile()

main ()

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question