Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 692 Bytes

File metadata and controls

51 lines (39 loc) · 692 Bytes

To and From String

int(myString)
str(myInt)
str(0b11010010)        # Gives 210
int("10", base=3)      # Gives 3

# Check type
type(int("10"))

Replace

theword = theword.replace("'", '"')

Strip

theword = theword.strip('.')

Substring

myString[2:8]

Find in text

if word in text:

Find in string

# string.find(s, sub[, start[, end]])
# Return -1 if not found

myString.find('s')
  
# OR
# string.index(s, sub[, start[, end]])
# raises an error ("traceback") if not found
myString.index('s')
  

Extract words from a text and put in a list

# See Python Array