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'))

     = )


  


)


Screen Shot 2018-05-04 at 6.37.49 PM.png

Screen Shot 2018-05-04 at 6.37.49 PM.png

# This pragram checks Far valid charge accaunt numbers
# Fram the charge_accaunts.txt File. deF maint):
# Get the list aF valid accaunt numbers. accauntNumbers - getListfi)
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:
printfi‘The charge number is valid.')
else:
printfi‘The charge number is invalid.')
# get the next charge number ta check.
chargeNumber - inputfi‘Enter a charge number ta check ar "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 - apenfl‘charge_accaunts.txt', ‘r'j chargeHumber - inputFile.readline() while chargeHumber ]- ":
chargeAccaunts.appendfichargeNumber.rstripfi‘fin'33
chargeNumber - inputFile.readline() return chargeAccaunts mainfi)

Recently Asked Questions

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
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question