I'm a beginner, so I'm sorry if I don't know how to ask questions.
I'm trying to create a matrix in Python 3 and write a code that replaces the elements in the matrix with input results.
It was possible to create a matrix with any number of elements in the basic_matrix in the figure, but how can I write a code to input all elements in the matrix and reflect the value in the basic_matrix?
For the time being, I tried to return the document according to the input value as shown in the image, but it didn't work either.
Input receives a string (str), so it is all NG compared to an integer (int).
if int(input("if relevant…")==1:
If you convert it to an integer like this, it will respond properly to the input value.
If you want to compare with the contents of the array (basic_matrix),
print(basic_matrix==1)
If you write the above outside of the for statement, it will remain in the form of an array, return the matching one with True, and return the non-conforming one with False.↓
[[True False False False]
False True False False False
False False True False False
False False False True False
False False False False True
I hope it will be helpful.
567 Who developed the "avformat-59.dll" that comes with FFmpeg?
595 GDB gets version error when attempting to debug with the Presense SDK (IDE)
566 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
877 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.