I have the following list:
str_list = [1,3,"foo bar",10]
What I want to do is to simply iterate through it print the results. Stop if the iteration meets "foo bar".
I tried the following code:
In [6]: for x in str_list:
...: print x
...: if x is "foo bar":
...: break
...:
It continues to print string with and after "foo bar". It didn't to to what I expect it to do, i.e. simply printing this:
1
3
What's the right way to do it?