I'm trying to figure out a way to see if a character in a string before another one to get and output. Say:
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")
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.
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.
If any of this does not make any sense, please feel free to reach me in the answer section.
Aucun commentaire:
Enregistrer un commentaire