I’m converting some java code to python code and I ended up getting stumped on how to convert a 2D array of objects in Java to python.
Java code:
private Node nodes[][] = new Node[rows][columns];
How would I do this in python?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
I think that’s what you want
But it is not always a good practice to initialize lists. For matrices it may make sense.
If you’re wondering: Documentation about list comprehensions
Demo code: