EGR 103/Fall 2018/Sandbox

From PrattWiki
Revision as of 14:47, 15 October 2018 by DukeEgr93 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  • Note the differences between the following ways of adding to a list:
as_letters = ['hello']
as_letters += 'there'
creates
['hello', 't', 'h', 'e', 'r', 'e']
while
as_word = ['hello']
as_word += ['there']
creates

<soucre lang=python> ['hello', 'there'] </source>

  • np.where(BOOLEAN) returns a tuple; to get to the actual indices, you need np.where(BOOLEAN)[0]. If you specifically only want the first place something is try in the BOOLEAN, use you need np.where(BOOLEAN)[0][0].