Python
String datatype:
- Jupter Notebook differences:
Without print method | With print method |
---|---|
Input: “Hello World String 1” “Hello World String 2” |
Input: print(“Hello World String 1”) print(“Hello World String 2”) |
Output: “Hello World String 2” |
Output: Hello World String 1 Hello World String 2 |
- String indexing and slice operation: Example, -
myString = 'abcdefghij'
Indexing Operations:
Input | Output |
---|---|
myString[0] | a |
myString[8] | i |
myString[-1] | j |
myString[-2] | c |
Slice Operations:
Input | Output |
---|---|
myString[2:] | cdefghij |
myString[:3] | abc |
myString[2:5] | cd |
myString[::] | abcdefghij |
myString[::2] | acegi |
myString[::3] | adgj |
myString[::-1] | jihgfedcba |
python-documentation is maintained by ravaan-techky.