|
2011-04-02
, 16:46
|
Posts: 136 |
Thanked: 150 times |
Joined on Dec 2010
@ Finland
|
#2
|
Slice indices have useful defaults; an omitted first index defaults to zero, an omitted second index defaults to the size of the string being sliced.
>>> word[:2] # The first two characters
'He'
>>> word[2:] # All but the first two characters
The Following User Says Thank You to mooglez For This Useful Post: | ||
|
2011-04-02
, 17:17
|
Posts: 291 |
Thanked: 398 times |
Joined on Jan 2011
@ USA
|
#3
|
|
2011-04-02
, 18:20
|
Posts: 123 |
Thanked: 99 times |
Joined on Sep 2010
@ Russia
|
#4
|
|
2011-04-02
, 18:33
|
Posts: 28 |
Thanked: 13 times |
Joined on Nov 2010
@ Tampere, Finland
|
#5
|
The Following User Says Thank You to mvuori For This Useful Post: | ||
|
2011-04-02
, 18:35
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#6
|
The Following User Says Thank You to Mentalist Traceur For This Useful Post: | ||
I am noob in python, I need help with the syntax to trimp the string with python.
str = '187790012345'
strlen = 4
newstr = ?
I like the newstr to return only first strlen of str.... like '1877'
How do i do that in an effective way? Thanks.