0

How to split string and extract substring

13th Dec 2018, 1:55 PM
Aaditya Jaiswal
Aaditya Jaiswal - avatar
6 Antworten
+ 5
Here are some examples; name = "SoloLearn" l = list(name) # split without delimiter # ['S','o','l','o','L','e','a','r','n'] ss1 = name[1:5] # substring from index 1 to index 4 # 'oloL' ss2 = name[4:] # substring from index 4 to the end of string # 'Learn' tagline = "Learn to Code for Free!" sp1 = tagline.split(" ") # split tagline using a space for delimiter # ['Learn','to','Code','for','Free!'] email = "someone@the.door.now" sp2 = email.split("@") # split email using @ for delimiter # ['someone','the.door.now'] Hope this helps, but seriously, these are all taught in the course, but I forget which chapter : )
14th Dec 2018, 9:09 AM
Ipang
+ 5
Aaditya you should've put C-language in Relevant Tags, not Python. (Edit) Good points to take from this: https://stackoverflow.com/questions/6679204/how-to-get-substring-in-c
18th Dec 2018, 10:52 AM
Ipang
0
Could rewrite the code in c lang
18th Dec 2018, 10:47 AM
Aaditya Jaiswal
Aaditya Jaiswal - avatar
0
I know how to split in python
18th Dec 2018, 10:47 AM
Aaditya Jaiswal
Aaditya Jaiswal - avatar
- 1
Hi,
13th Dec 2018, 2:58 PM
Masod
- 1
what strings?
13th Dec 2018, 3:39 PM
Masod