I tried this but it doesn't work, words are printed with no spaces and I get errors

$x^\lambda_p = \begin{dcases*} 1 & if \lambda is assigned to P\\ 0 & Otherwise \end{dcases*}$

• Next time, maybe try to think of a more descriptive question title :). Mar 28 at 22:24

Be sure to use \$ in the right places (but not in the wrong places):
\documentclass{article}
$x^\lambda_p = \begin{dcases*} 1 & if \lambda is assigned to p \\ 0 & otherwise \end{dcases*}$