Skip to content

Instantly share code, notes, and snippets.

@aaronlelevier
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save aaronlelevier/409f624c73de167fe3bf to your computer and use it in GitHub Desktop.

Select an option

Save aaronlelevier/409f624c73de167fe3bf to your computer and use it in GitHub Desktop.
Notes for Saturday May 30th
''' String Methods '''
s = 'Jack the Crazy Giant'
# methods
s.upper()
s.lower()
# will return false because Python is case sensitive
s.startswith('j')
# indexing
s[0]
s[2:]
s[3:7]
s[-1]
s[-2:]
# can concatenate, but must be the same type
s + ' yo you'
# raises an error because different types
s + 1
# cast as a string (str)
s + str(1)
# strings have integer values, and vice versa
int_a = ord('a')
chr_100 = chr(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment