Python example to manipulate with some text
Code: "jehep_python.py". Programming language: Python DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/jehep_python_4299.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



s = "mary had a little lamb"
print s[0]          # index is zero-based
print s[11:18]      # 'slice' a subsequence
print s[:4]         # empty slice-begin assumes zero
print s[5:-5]       # can use "from end" index with negatives
print s[:5]+s[5:]   # slice-begin & slice-end are complimentary

Ads help maintain this website.