Using a for loop I get the data:
58738121385139B
9135A4251EF0
2B631B53C383
I’m trying to get this data into one line separated by commas using
a = ', '.join(b);
but I get a comma after every character 5,8,7,3,8,1,2,1…
Please tell me how to get data 58738121385139B,9135A4251EF0,2B631B53C383 of this type.
>Solution :
- depends on your result and description, I guess your code is something like:
b = """58738121385139B
9135A4251EF0
2B631B53C383"""
print(', '.join(b))
result:
5, 8, 7, 3, 8, 1, 2, 1, 3, 8, 5, 1, 3, 9, B,
, 9, 1, 3, 5, A, 4, 2, 5, 1, E, F, 0,
, 2, B, 6, 3, 1, B, 5, 3, C, 3, 8, 3
- you should use
splitto achieve it
print(', '.join(b.split("\n")))
result:
58738121385139B, 9135A4251EF0, 2B631B53C383
- Next time pls post your whole code to give us a MRE(https://stackoverflow.com/help/minimal-reproducible-example), not let us try to guess your code.