-3

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
khelwood
  • 55,782
  • 14
  • 81
  • 108
Raaj
  • 3
  • 2

2 Answers2

0

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")
0

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")
Bhagyesh Dudhediya
  • 1,800
  • 1
  • 13
  • 16