+ 1
Will somebody tell me.
what is a substring.
4 Antworten
+ 12
it is a part of a string, for example:
given the string "this is a string"
here are some examples of substrings of it
"this"
"a string"
"is a str"
basically any sequence of letters that is also in the original string
+ 1
a = "this is a string"
>>> a[4:]
' is a string'
>>> a[0:4]
'this'
>>> a[10:]
'string'
>>> a[::-1]
'gnirts a si siht'
0
Do you mean slicing?
0
A substring is a slice of a string, you use them when you need specific sections of a string