If a character in string is found before another character
<p>I'm trying to figure out a way to see if a character in a string before another one to get and output. Say:</p>

<pre><code>v="Hello There"
x=v[0]

if "Hello" in x:
    print("V consists of '"'Hello'"'")
        if "There" in x:
             print("Hello comes before There)

if "There" in x:
    print("V consists of '"'There'"'")
        if "Hello" in x:
             print("There comes before Hello")
</code></pre>

<p>What I'm trying to get is "Hello comes before There", though it doesn't seem to work when I type it in. Help would be greatly appreciated.</p>

<p>The reason why the output would indicate that Hello comes before there is because the script is read from top to bottom, and this is just an exploit of that fact.</p>

<p>If any of this does not make any sense, please feel free to reach me in the answer section.</p>

<pre><code>v="Hello There".split()                    #splitting the sentence into a list of words ['Hello', 'There'], notice the order stays the same which is important
                                           #got rid of your x = v[0] since it was pointless
if "Hello" in v[0]:                        #v[0] == 'Hello' so this passes
    print("V consists of '"'Hello'"'")
    if "There" in v[1]:                    #v[1] == 'There' so this passes. This line had indentation errors
        print("Hello comes before There")  # This line had indentation errors

if "There" in v[0]:                        #v[0] == 'Hello' so this fails
    print("V consists of '"'There'"'")
    if "Hello" in v[1]:                    #v[1] == 'There' so this fails. This line had indentation errors
        print("There comes before Hello")  # This line had indentation errors
</code></pre>

<p>Fixed your code with some comments to show you what's happening and what not. You had indentation errors too.</p>

<p>If you want a better coding practice see Patrick's answer. I just wanted to show you what you were doing wrong</p>

python string variables if-statement