LEARN MongoDB AND PYTHON: Coding For Beginners! MongoDB AND PYTHON Crash Course, A QuickStart Guide, Tutorial Book by Program Examples, In Easy Steps! by JJ TAM

LEARN MongoDB AND PYTHON: Coding For Beginners! MongoDB AND PYTHON Crash Course, A QuickStart Guide, Tutorial Book by Program Examples, In Easy Steps! by JJ TAM

Author:JJ TAM [TAM, JJ]
Language: eng
Format: azw3
Published: 2020-05-03T16:00:00+00:00


>>> name[ - 2 ]

'l'

>>> name[ - 7 ]

'o'

Slicing

Slicing is used to get sub string of given string.

Example

Description

string[start:end]

Returns sub string from index start (included) to end index (excluded).

string[:end]

Returns sub string from index 0(included) to end index (excluded).

string[start:]

Return sub string from index start to till end.

string[-2:]

Return characters from 2 nd last to end.

>>> message = "Hello World"

>>>

>>> message[ 0 : 5 ]

'Hello'

>>> message[ 5 :]

' World'

>>> message[:]

'Hello World'

>>> message[ - 2 :]

'ld'

>>> message[ - 5 : - 2 ]

'Wor'

Get length of the string

Function ‘len(str)’ is used to get the length of the string.

>>> message

'Hello World'

>>> len(message)

11

>>> len( "How are you " )

11



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.