0

I'm using a mySQL database on uwamps to store data on names and highscores of people who've played a game, and I need to get that data into a 2D array. So far, I've managed to get the data in as a 1D array, which looks like this when i print it:

[('name1', 4), ('name2', 3), ('name3', 2), ('name4', 6), ('name5', 1)]

I need what's inside each set of normal brackets to be a seperate list, like this:

 [['name1', 4], ['name2', 3], ['name3', 2], ['name4', 6], ['name5', 1]]

Any idea how to do this?

sloth
101k21 gold badges183 silver badges224 bronze badges
asked Jan 14, 2020 at 10:20
2
  • The '' mean its a string. You cannot remove that, its part of the python syntax not the text itself. And please provide an example of what your output should look like Commented Jan 14, 2020 at 10:22
  • the apostrophes indicate that the name is a string, you probably want that. Commented Jan 14, 2020 at 10:22

1 Answer 1

2

just convert the touples to a list:

userscores=[('name1', 4), ('name2', 3), ('name3', 2), ('name4', 6), ('name5', 1)]
userscores=[list(user) for user in userscores]
answered Jan 14, 2020 at 10:26
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.