Python Forum
Conversion of ['a', 'b'] to { 'letter': 'a,b' }
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conversion of ['a', 'b'] to { 'letter': 'a,b' }
#1
Dear Experts!
Please advise how to convert(to take the A and from [this list]):
['A', 'B']
and update the 'letter' in {this dictionary}:
 { 'letter': 'A,B' }   # no spaces between A and B
Reply
#2
How it work here is that you give it a try(code) and explain what the problem is.
Here a start.
>>> lst = ['A', 'B']
>>> vaule = ','.join(lst)
>>> vaule
'A,B'
>>> 
>>> d = {}
>>> ... 
Reply
#3
1st step:
convert ['A','B'] to a single string with a comma like 'A,B'

2nd step:
create a new dictionary with key = letter, value = 'A,B'
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020