Python File Senate113sortedtxt Contains List 100 Us Senators Made 113th Senate Sorted Alph Q37153980

In Python

The file Senate113_sorted.txt contains a list of the 100 USSenators that made up the 113th Senate, sorted in alphabeticalorder by Senator last name. Write a function named different_partythat accepts one argument, a file name, and returns a list of USstates whose Senators come from 2 different political parties (asindicated by D, R, or I).

Here’s a few rows from the file

Lamar Alexander,Tennessee,R
Kelly Ayotte,New Hampshire,R
Tammy Baldwin,Wisconsin,D
John Barrasso,Wyoming,R
Max Baucus,Montana,D
Mark Begich,Alaska,D
Michael Bennet,Colorado,D
Richard Blumenthal,Connecticut,D
Roy Blunt,Missouri,R
John Boozman,Arkansas,R
Barbara Boxer,California,D
Sherrod Brown,Ohio,D
Richard Burr,North Carolina,R
Maria Cantwell,Washington,D
Benjamin Cardin,Maryland,D
Thomas Carper,Delaware,D
Robert Casey,Pennsylvania,D
Saxby Chambliss,Georgia,R
Dan Coats,Indiana,R
Tom Coburn,Oklahoma,R


Solution


I have implemented the code as required. As in the givenexample, there are no states with

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.