+ 4

Separating values with "comma" as a delimiter ?

I'm working with a project, in this there will be variable holding any data types just separated with a comma. I need to separate all these things and also need to define which type it is. For e.g: data="Hello, Hey",123,10.04 I used split() function to separate, but it separates the comma even within the string "Hello,Hey" I don't need like this, all i need is, just to separate the values by commas but not by the commas inside the string. I killed my brain, but it is still a problem for me.

29th Jun 2018, 4:52 PM
Hemath Kumar
Hemath Kumar - avatar
15 ответов
29th Jun 2018, 6:20 PM
davy hermans
davy hermans - avatar
+ 4
And here is my Need !! https://code.sololearn.com/cY6rwq9f5KB1/?ref=app Got this from Stack Overflow
29th Jun 2018, 6:39 PM
Hemath Kumar
Hemath Kumar - avatar
+ 3
Sorry Hemath Kumar I cant seem to figure it out But i think this should help: https://code.sololearn.com/cY6rwq9f5KB1/?ref=app
29th Jun 2018, 5:16 PM
Agent
Agent - avatar
+ 3
thanks for all ! finally got the solution !! All of your solutions were almost matched my need !! But I got the complete result in "re module"
29th Jun 2018, 6:33 PM
Hemath Kumar
Hemath Kumar - avatar
29th Jun 2018, 5:38 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
Agent actually I need that comma inside the string and my string should be a single one !! like if you use print statement in Python, like this print "Hey Machi, How are you",123 I need the comma within the string is not be touched!!
29th Jun 2018, 5:12 PM
Hemath Kumar
Hemath Kumar - avatar
+ 1
Okay Agent just leave.... some others will help
29th Jun 2018, 5:17 PM
Hemath Kumar
Hemath Kumar - avatar
+ 1
try putting this in front of the coma \
29th Jun 2018, 5:21 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
davy hermans let me elaborate my whole problem.... actually my project is a lexer, which will tokens my input. It need to separate the values and specify which data type it is..!! There's no matter, if my print status has only one value, but if there are many, which are separated by comma, I need to make the tokens for them too by splitting it up.... so now, as in this point of view, my "data" variable is not a tuple, it is a string it actually looks like, data = ' "Hey, Hello",123 ' now I need to separate this!!
29th Jun 2018, 5:22 PM
Hemath Kumar
Hemath Kumar - avatar
+ 1
Hemath Kumar are hey and hello separate or together?
29th Jun 2018, 5:29 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
no, they are single string, like print "Hello, Hey"
29th Jun 2018, 5:30 PM
Hemath Kumar
Hemath Kumar - avatar
+ 1
or "Hello, Longtie"
29th Jun 2018, 5:30 PM
Hemath Kumar
Hemath Kumar - avatar
+ 1
I think this is exactly what u want Please inform me if it was exactly what u wante or you need some more changes. https://code.sololearn.com/c7oW2j7yp1Mf/?ref=app
29th Jun 2018, 5:43 PM
Pulkit Kamboj
Pulkit Kamboj - avatar
0
if data is a tuple (as it looks to be) you could use: for i in data: print(i) or is it a string holding these elements?
29th Jun 2018, 5:17 PM
davy hermans
davy hermans - avatar
0
LONGTIE actually your answer is good enough, but my problem is above, just read it out and give me the solution pls
29th Jun 2018, 5:24 PM
Hemath Kumar
Hemath Kumar - avatar