Show Menu
Cheatography

Python Cheat Sheet (DRAFT) by

Introduction to python

This is a draft cheat sheet. It is a work in progress and is not finished yet.

String methods

 

String methods

print (name.u­pp­er())
prints the variable in uppercase
print (name.l­ow­er())
prints the variable in lowercase
print(­nam­e.c­api­tal­ize())
prints the variable with a capital
print (name.c­ou­nt(­"­a"))
counts the number of a's in the variable
print (name.r­ep­lac­e("n­", "­m"))
replaces the n's with m's
print (name.r­ep­lac­e("h­", "­"))
replaces all the h's with nothing, removing the letter
A method is placed after the variable with a . between them and nearly always end with ().