0
How to split string and extract substring
6 Réponses
+ 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 : )
+ 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
0
Could rewrite the code in c lang
0
I know how to split in python
- 1
Hi,
- 1
what strings?