0
Is there any code in Python to cut a string as we used to in HTML? HTML Example, left ("abcd",1) gave "a" So anything like this in Python?
2 odpowiedzi
+ 2
If you want an individual character you can access them using by their index.
e.g
s="abc"
print(s[0]) #outputs 'a'
If you want to receive part of the string, you can split it.
e.g
print(s[0:2]) #outputs 'ab'
This app covers this btw so better start using it.
+ 1
"abcd"[0] will give you "a"