-3

I do not know what I am missing but I've tried 3 different ways to achieve basically the same thing. Looking at the code below, why does only 1 out of the 4 ways work. I want to see if a value (located in a list) exists inside another list. I checked this SO question but still not understanding why the code is failing to print True1 , True2, and True4.

l1 = ["bravo", "alhpa", "charlie"]

l2 = ["alpha"]


if l1[1] in l2:
    print "True1"  # does not work

if l1[1] == l2[0]:
    print "True2"  # does not work

if "alpha" in l2:
    print "True3"  # works

for outer in l1:
    for inner in l2:
        if outer == inner:
            print "True4"  # does not work
Kervvv
  • 751
  • 4
  • 14
  • 27

1 Answers1

3

You have a typo: "alhpa" vs. "alpha"

Shai
  • 111,146
  • 38
  • 238
  • 371
  • 1
    HOW EMBARRASSING!!!! Thank you! They all print now. Will accept as answer once it allows me to. That is what happens when I stare at just one thing too long – Kervvv May 29 '17 at 06:32