Create list named states1 that holds the two-letter


Write program named program71.py as follows. Follow instructions carefully to avoid point deductions.

In the main function:

  • create list named states1 that holds the two-letter abbreviations of the first 10 USA states, in alphabetical order.
  • use a loop to process the list and display the abbreviations all on the same line, separated by a single space. See sample output.
  • make a second list named states2 by slicing. This new list must hold the middle four state abbreviations from states1.
  • execute a function named list_func with states2 as its sole argument.
  • inside the list_func function:
  • delete the second element in the list
  • insert the abbreviation for Texas into the list at index 2
  • prompt the user for the abbreviation of another state of your choice, then append it to the list
  • reverse the list
  • return the list to main
  • back in main, use a loop to iterate over the returned list, printing all abbreviations on one line separated by a space.

Sample Output

Initial list of state abbreviations

AL AK AZ AR CA CO CT DE FL GA 

Enter the state abbreviation for Kentucky KY

List returned by list_func

KY CT TX CO AR

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Create list named states1 that holds the two-letter
Reference No:- TGS02511698

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)