Modify the program so that it allows a user to change a given element of the lis
ID: 3542421 • Letter: M
Question
Modify the program so that it allows a user to change a given element of the list.
# Get the table # Initialize the list wins = [] # Get the number of teams in the leaguenumTeams - int(input("How many teams are in the league? ")) # Loop through the rows in the table for i in range(numTeams): # Initialize the row row = [] # Loop through each of the teams in this row for j in range(numTeams): # Get the number of wins num = int(input("Wins by team " + str(i) + " at team " + str(j) + ": ")) # Insert the number of wins into the row row = row + [num] # Insert the row into the table wins = wins + [row] # Intialize the mostWins mostWins wins[0][0] # Nested loop to process the table for i in range(numTeams): for j in range(numTeams): if wins[i][j] > mostWins: mostWins = wins[i][j] # Print the result print("The most wins = ", mostWins)Explanation / Answer
#Get the index to change from the user
changeIndex=int(input("Enter index to change"))
value=int(input("Enter changed value"))
wins[i][changeIndex]=value
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.