0
me={'name': 'adeen', 'passion': ['reading','gardening']}

How could I change 'reading' in it or if I have placed a variable in it?

Blckknght
  • 100,903
  • 11
  • 120
  • 169
  • Does this answer your question? [Python: How do I replace value in a nested list?](https://stackoverflow.com/questions/51318249/python-how-do-i-replace-value-in-a-nested-list) – AS11 Apr 03 '21 at 05:01
  • Welcome to Stack Overflow. You may want to take the [tour] to learn more about the site. I've reformatted your question a bit to make the code parts a bit clearer. I also did some light editing, please feel free to [edit] yourself if you think you can improve the question. I'm not sure I understand what the second part of your question about variables is referring to. Can you clarify a bit, perhaps with some more code, if you've tried some things. – Blckknght Apr 03 '21 at 06:02

1 Answers1

0

You can change values (Nested lists) by their index and dictionary key. If you want change 'reading' value, you can do it:

me
{'name': 'adeen', 'passion': ['reading', 'gardening']}
me['passion']
['reading', 'gardening']
me['passion'][0] = 'Hello'
me
{'name': 'adeen', 'passion': ['Hello', 'gardening']}
Omid Khalaf Beigi
  • 187
  • 1
  • 2
  • 12