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
  • 99,095
  • 21
  • 171
  • 219
Nico
  • 101
  • 9
  • 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 – sshashank124 Jan 14 '20 at 10:22
  • the apostrophes indicate that the name is a string, you probably want that. – Bendik Knapstad Jan 14 '20 at 10:22

1 Answers1

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]
Bendik Knapstad
  • 1,409
  • 1
  • 9
  • 18