Hi there, I was doing a string exercise and the result was odd to me.
So this task requests me to separate the strings in a list through comma ( ‘,’).
It’s a nested list, and I try splitting and append them to a new list. The result turned out just fine.
medical_data_split =['Marina Allison ,27 , 31.1 , \n$7010.0 ', 'Markus Valdez , 30, \n22.4, $4050.0 ', 'Connie Ballard ,43 \n, 25.3 , $12060.0 ', ‘Darnell Weber \n, 35 , 20.6 , $7500.0’, '\nSylvie Charles ,22, 22.1 \n,$3022.0 ', ’ Vinay Padilla,24, \n26.9 ,$4620.0 ‘, ‘Meredith Santiago, 51 , \n29.3 ,$16330.0’, ’ Andre Mccarty, \n19,22.7 , $2900.0 ‘, ’ \nLorena Hodson ,65, 33.1 , $19370.0’, ’ \nIsaac Vu ,34, 24.8, $7045.0’]
Syntax:
for record in medical_data_split:
record.split(“,”)
medical_records.append(record)
However as the project goes on, I got incorrect results. I reviewed all my step and found only the mentioned part is different from the official answer.
Hinted syntax:
for record in medical_data_split:
medical_records.append(record.split(“,”))
The official answer looks to me was only a concise version of what I wrote. Can anyone tell me what causes the difference? Thanks in advance!