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?

7th Aug 2016, 7:18 AM
Shashank Keshari
Shashank Keshari - avatar
2 Antworten
+ 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.
7th Aug 2016, 10:15 AM
Gershon Fosu
Gershon Fosu - avatar
+ 1
"abcd"[0] will give you "a"
1st Oct 2016, 1:36 PM
HESHAM ELMAHDY
HESHAM ELMAHDY - avatar