Re: If a dictionary key has a Python list as its value!

2024-03-07 Thread Mats Wichmann via Python-list
On 3/7/24 07:11, Varuna Seneviratna via Python-list wrote: If a dictionary key has a Python list as its value, you can read the values one by one in the list using a for-loop like in the following. d = {k: [1,2,3]} for v in d[k]: print(v) No tutorial describes this, why? What

Re: If a dictionary key has a Python list as its value!

2024-03-07 Thread MRAB via Python-list
On 2024-03-07 14:11, Varuna Seneviratna via Python-list wrote: If a dictionary key has a Python list as its value, you can read the values one by one in the list using a for-loop like in the following. d = {k: [1,2,3]} for v in d[k]: print(v) No tutorial describes this, why? What

If a dictionary key has a Python list as its value!

2024-03-07 Thread Varuna Seneviratna via Python-list
If a dictionary key has a Python list as its value, you can read the values one by one in the list using a for-loop like in the following. d = {k: [1,2,3]} > for v in d[k]: > print(v) No tutorial describes this, why? What is the Python explanation for this behaviour? Varuna --