-3

I have list:

['Happy Family','2122540624','213 E Broadway # A, New York, NY 10002, United States']

I want to add a ',' into first item like this:

 ['Happy Family,','2122540624','213 E Broadway # A, New York, NY 10002, United States']

Any friend know how to do it?

William
  • 3,724
  • 9
  • 43
  • 76
  • 2
    Please be aware [so] is not a code-writing service. We can help solve specific, technical problems, not open-ended requests for code or advice. Please [edit] your question to show what you have tried so far, and what specific problem you need help with. See the [ask] page for details how to best help us help you. – MisterMiyagi Aug 17 '20 at 19:32

2 Answers2

3
MyList = ['Happy Family','2122540624','213 E Broadway # A, New York, NY 10002, United States']
MyList[0] = MyList[0] +','

Result:

['Happy Family,', '2122540624', '213 E Broadway # A, New York, NY 10002, United States']

You can try it

dawg
  • 98,345
  • 23
  • 131
  • 206
1

You just need to get the item by index and add a comma as below:

a = ['Happy Family','2122540624','213 E Broadway # A, New York, NY 10002, United States']
a[0] = f'{a[0]},' # f-string above python 3.6 otherwise a[0] = a[0] + ','
print(a) # Outputs ['Happy Family,', '2122540624', '213 E Broadway # A, New York, NY 10002, United States']
Brad Figueroa
  • 869
  • 6
  • 15