Analyzing string input until it reaches a certain letter on Python
The built-in str.partition() method will do this for you. Unlike str.split() it won’t bother to cut the rest of the str into different strs. text = raw_input(“Type something:”) left_text = text.partition(“!”)[0] Explanation str.partition() returns a 3-tuple containing the beginning, separator, and end of the string. The [0] gets the first item which is all you … Read more