# Convert tuple to list and back

| | | | | | | |

👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!

I"m currently working on a map editor for a game in pygame, using tile maps. The level is built up out of blocks in the following structure (though much larger):

``````level1 = (
(1,1,1,1,1,1)
(1,0,0,0,0,1)
(1,0,0,0,0,1)
(1,0,0,0,0,1)
(1,0,0,0,0,1)
(1,1,1,1,1,1))
``````

where "1" is a block that"s a wall and "0" is a block that"s empty air.

The following code is basically the one handling the change of block type:

``````clicked = pygame.mouse.get_pressed()
if clicked[0] == 1:
currLevel[((mousey+cameraY)/60)][((mousex+cameraX)/60)] = 1
``````

But since the level is stored in a tuple, I"m unable to change the values of the different blocks. How do I go about changing the different values in the level in an easy manner?

👻 Read also: what is the best laptop for engineering students?

We hope this article has helped you to resolve the problem. Apart from Convert tuple to list and back, check other code Python module-related topics.

Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.

By the way, this material is also available in other languages:

Carlo Richtgofen

Rome | 2023-01-27

Thanks for explaining! I was stuck with Convert tuple to list and back for some hours, finally got it done 🤗. Will use it in my bachelor thesis

Schneider Zelotti

Moscow | 2023-01-27

Thanks for explaining! I was stuck with Convert tuple to list and back for some hours, finally got it done 🤗. Will use it in my bachelor thesis

Julia Galleotti

Warsaw | 2023-01-27

Maybe there are another answers? What Convert tuple to list and back exactly means?. Checked yesterday, it works!

## Shop

Learn programming in R: courses

\$FREE

Best Python online courses for 2022

\$FREE

Best laptop for Fortnite

\$399+

Best laptop for Excel

\$

Best laptop for Solidworks

\$399+

Best laptop for Roblox

\$399+

Best computer for crypto mining

\$499+

Best laptop for Sims 4

\$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

PythonStackOverflow

Check if one list is a subset of another in Python

PythonStackOverflow

How to specify multiple return types using type-hints

PythonStackOverflow

Printing words vertically in Python

PythonStackOverflow

Python Extract words from a given string

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

PythonStackOverflow

Python os.path.join () method

PythonStackOverflow

Flake8: Ignore specific warning for entire file

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries