Can anyone write separation function ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Can anyone write separation function ?

Can anyone write a function separating each genre by itself in Chan de Cactar Example: "hjd 652hf7 * 4,5+-4 (uy 5+4" The result is hjd # 652 # hf # 7 # * # 4,5 #+# -4 #(#uy#5#+#4 Genres → alphabet/float/integer/operation/sign of number (+ or - → positive or negative) If it's a sign → #+2# If it's a operation → #+#2#

8th Feb 2021, 5:02 PM
Zeineb
Zeineb - avatar
38 Answers
+ 5
Abol i think op wants the answer in the format , "#hello#984#worl#8#-#9#a9#(#)#3,9#+#(#-9#) " for input " hello 984 world 8-9a9 () 3,9+(-9)"
8th Feb 2021, 8:12 PM
Abhay
Abhay - avatar
+ 4
What does the e.split("#") do?
8th Feb 2021, 10:11 PM
mar ia
mar ia - avatar
+ 4
Hi! In the line: dic={k:gettyp(k) for k in e.split("#")} a dictionare is building up with k as key and gettyp(k) as value, whatever the function will return when k is an argument. k is a variable that will iterate through the lists e.split(”#”):s element in the same way as a for loop can do. e is a string and everywhere ”#” is in that string the string will split and the parts between the ”#” become the lists element. /Regards Per B 🙂
8th Feb 2021, 10:38 PM
Per Bratthammar
Per Bratthammar - avatar
+ 4
iterate through th string. if type of char changes, seperate.
9th Feb 2021, 6:49 AM
Oma Falk
Oma Falk - avatar
+ 4
Abol your code is outputting "#5#-4" for "5+-4" But it should output "#5#+#-4" .
9th Feb 2021, 11:29 AM
Abhay
Abhay - avatar
+ 3
No, she means that: Entries are normal strings And you are working on separating it so that it is like this Input mam 3-6 (5) -4 * 6/3 Result #mam#3#-#6#(#5#)#-4#*#6#/#3
8th Feb 2021, 9:12 PM
mar ia
mar ia - avatar
+ 3
Abol I need just the 2nd input Thank u 😊
9th Feb 2021, 11:21 AM
Zeineb
Zeineb - avatar
+ 3
May God protect you👐Abol
9th Feb 2021, 11:25 AM
mar ia
mar ia - avatar
+ 3
thank u Abol may god protect you
12th Feb 2021, 6:13 AM
mar ia
mar ia - avatar
+ 3
#Can anyone write separation function ? #Can anyone write a function separating each genre by itself in Chan de Cactar Example: "hjd 652hf7 * 4,5+-4 (uy 5+4" #The result is hjd # 652 # hf # 7 # * # 4,5 #+# -4 #(#uy#5#+#4 #Genres → alphabet/float/integer/operation/sign of number (+ or - → positive or negative) #If it's a sign → #+2# #If it's a operation → #+#2# list=('hjd','652' ,'hf', '7', '*' ,'4,5' ,'+', '-4' ,'(','uy','5','+') print (list)
16th Feb 2021, 5:22 PM
Irfan Shaikh
Irfan Shaikh - avatar
+ 3
Here may be answer for ur question
16th Feb 2021, 5:22 PM
Irfan Shaikh
Irfan Shaikh - avatar
+ 2
mar ia split converts a string into an array or list with the delimiter as the separator
9th Feb 2021, 3:07 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 2
mar ia you can take a look at my code as well , it isn't perfect as the exact requirements aren't clear to me but it does it job. https://code.sololearn.com/c0HTVjfCV9kW/?ref=app
11th Feb 2021, 9:53 AM
Abhay
Abhay - avatar
+ 2
why when i change "a" string to input it didt'n worck https://code.sololearn.com/cBsov5Z4utfg/?ref=app
11th Feb 2021, 10:12 AM
mar ia
mar ia - avatar
+ 2
#Can anyone write separation function ? #Can anyone write a function separating each genre by itself in Chan de Cactar Example: "hjd 652hf7 * 4,5+-4 (uy 5+4" #The result is hjd # 652 # hf # 7 # * # 4,5 #+# -4 #(#uy#5#+#4 #Genres → alphabet/float/integer/operation/sign of number (+ or - → positive or negative) #If it's a sign → #+2# #If it's a operation → #+#2# list=('hjd'+" "+'652'+" "+'hf'+" " +'7'+" "+ '*' +" "+'4,5' +" "+'+'+" " +'-4' +" "+'('+" "+'uy'+" "+'5'+" "+'+') print (list)
17th Feb 2021, 1:25 PM
Irfan Shaikh
Irfan Shaikh - avatar
+ 1
Abol how can I separate the 2 functions (who separate with # and the one who delete #) → separate the 2 inputs after "gettyp2"
11th Feb 2021, 9:29 AM
mar ia
mar ia - avatar
+ 1
Abol if you can write what every statment do because it's not clear well
11th Feb 2021, 9:30 AM
mar ia
mar ia - avatar
+ 1
Finally done
17th Feb 2021, 1:25 PM
Irfan Shaikh
Irfan Shaikh - avatar
+ 1
11th Mar 2021, 6:14 AM
Zeineb
Zeineb - avatar
+ 1
It's my pleasure
11th Mar 2021, 2:05 PM
Irfan Shaikh
Irfan Shaikh - avatar