x = input("enter input: ")
if x == "hello":
print ("it does")
How would I detect if x has hello stored even if it has other charaters/strings?
x = input("enter input: ")
if x == "hello":
print ("it does")
How would I detect if x has hello stored even if it has other charaters/strings?
This is as simple as using the in
keyword.
x = "123hellomore"
if "hello" in x:
print("Hi there")
This only detects hello
, if it is unobstructed so still in one word (not like "**hel*lo")
If entered input is single string then x below will be array of one element, if entered input is space separated strings (string of strings) then x will be array of multiple strings, below code handles both options
x = input("Enter input: ").split()
for y in x:
if y=="hello"
print("it does")