I have 10 arrays on my array and I have 10 lines of numbers are in numbers.txt file.
How to code in python that I need to get a print("The process completed")
if my Array len counts and text file line counts are equal then I need to print a message.
Array:
number = [124,589,478,547,745,256,321,654,665,888]
Text File: numbers.txt
124
589
478
547
745
256
321
654
665
888
CodePudding user response:
Here if you just want to check the length you can do it like below.
number = [124,589,478,547,745,256,321,654,665,888]
f = open('numbers.txt','r')
if len(number) == len(f.readlines()):
print("The process completed")
CodePudding user response:
This is one of the ways to obtain what you want:
number = [124,589,478,547,745,256,321,654,665,888]
with open('numbers.txt','r') as f:
if len(number) == len(f.readlines()):
print("The process completed")
else:
print("The process is not yet completed")