Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6986501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:49:01+00:00 2026-05-27T18:49:01+00:00

I am writing a Python program that creates a 9×9 matrix with all of

  • 0

I am writing a Python program that creates a 9×9 matrix with all of the values being 0. Then I have to manually put in the a actual values I want to be in it. (That is why I have all of the inserts.) I am trying to use the list.remove(x) command with list being the matrix and x being the value I am trying to remove. I know that the x value I am putting in is in the matrix but I keep getting an error saying it isn’t.

Here is my code:

matrix = [[0 for x in range (9)] for y in range (9)]
C = matrix.count([0, 0, 0, 0, 0, 0, 0, 0, 0])
matrix.insert(0, [0, 0, 0, 5, 0, 0, 0, 0, 6])
matrix.insert(0, [8, 0, 0, 0, 4, 7, 5, 0, 3])
matrix.insert(0, [0, 5, 0, 0, 0, 3, 0, 0, 0])
matrix.insert(0, [0, 7, 0, 8, 0, 0, 0, 0, 9])
matrix.insert(0, [0, 0, 0, 0, 1, 0, 0, 0, 0])
matrix.insert(0, [9, 0, 0, 0, 0, 4, 0, 2, 0])
matrix.insert(0, [0, 0, 0, 9, 0, 0, 0, 1, 0])
matrix.insert(0, [7, 0, 8, 3, 2, 0, 0, 0, 5])
matrix.insert(0, [3, 0, 0, 0, 0, 8, 0, 0, 0])
matrix.reverse()
for sublist in matrix:
    s = str(sublist)
    print (s)
print (C)
matrix.remove("[0, 0, 0, 0, 0, 0, 0, 0, 0]")

Here is the error I keep getting:

Traceback (most recent call last):
line 17, in <module>
matrix.remove("[0, 0, 0, 0, 0, 0, 0, 0, 0]")
ValueError: list.remove(x): x not in list

I also tried using this code but Python seems to just find that it isn’t in the matrix anyways. This I put in place of matrix.remove(“[0, 0, 0, 0, 0, 0, 0, 0, 0]”) Here it is:

if "[0, 0, 0, 0, 0, 0, 0, 0, 0]" in matrix:
    matrix.remove("[0, 0, 0, 0, 0, 0, 0, 0, 0]")

I am very new to Python and am still learning. Any help you might give me would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:49:02+00:00Added an answer on May 27, 2026 at 6:49 pm

    Change:

     matrix.remove("[0, 0, 0, 0, 0, 0, 0, 0, 0]")
    

    to:

     matrix.remove([0, 0, 0, 0, 0, 0, 0, 0, 0])
    

    The list you’re looking for isn’t a string; it’s a list; no need to put it through as a string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear all, I am writing a python program that is retrieving edifact log messages
I am writing a python program that lauches a subprocess (using Popen). I am
I am writing a program in Python that will act as a server and
I am writing a program in Python, and I realized that a problem I
I have a Python program that processes fairly large NumPy arrays (in the hundreds
I'm writing a personal wiki-style program in Python that stores text files in a
I'm writing a python program that will spawn a subprocess to basically clone a
I'm writing a python program that deals with a fair amount of strings/files. My
I'm writing a python program that needs to set the environment CFLAGS as needed.
I'm writing a Python program that logs terminal interaction (similar to the script program),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.