View the step-by-step solution to:

# # This pragram checks Far valid charge accaunt numbers # Fram the charge_accaunts.txt File. deF maint): # Get the list aF valid accaunt numbers....

Need some assistance with this program.

# This program checks for valid charge account numbers

# from the charge_accounts.txt file.

):

# Get the list of valid account numbers.

= )

5658845, 4520125, 7895122, 8777277, 8451277, 1302850,

8080152, 4562555, 5552012, 5050552, 7825877, 1250255

= a charge number to check "exit" to end: ')

= 'exit':

' .')

:

'The charge number is invalid.')

# get the next charge number to check.

= a to check"exit" to end: ')

# The function gets the list of valid account numbers from the

# charge_accounts.txt file and returns it.

):

# create empty list

= []

# open the charge_accounts.txt file.

= open'charge_accounts', '')

= )

= '':

rgeAccounts.append(chargeNumber.rstrip('n'))

= )

)

# This pragram checks Far valid charge accaunt numbers
# Fram the charge_accaunts.txt File. deF maint):
# Get the list aF valid accaunt numbers. accauntNumbers - getListﬁ)
5353345, 4523125, 2395122, 3222222, 3451222, 1332353,
3333152, 4532555, 5552312, 5353552, 2325322, 1253255 chargeHumber - input[‘Enter a charge number ta check or “e:u:it‘I ta end: ')
while chargeHumber ]- ‘exit':
iF chargeHumber in accauntHumbers:
printﬁ‘The charge number is valid.')
else:
printﬁ‘The charge number is invalid.')
# get the next charge number ta check.
chargeNumber - inputﬁ‘Enter a charge number ta check ar &quot;e:«cit‘| ta end: '3 # The getList Functian gets the list aF valid accaunt numbers From the
# charge_accaunts.txt File and returns it.
deF getList(): # create empty list chargeAccaunts - E] # apen the charge_accaunts.txt File. inputFile - apenﬂ‘charge_accaunts.txt', ‘r'j chargeHumber - inputFile.readline() while chargeHumber ]- &quot;:
chargeAccaunts.appendﬁchargeNumber.rstripﬁ‘ﬁn'33
chargeNumber - inputFile.readline() return chargeAccaunts mainﬁ)

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents