def tester(p, givenstring = "Too short"):
result=len(p)
if result>=10:
print(p)
else:
print(givenstring)
#Comments should be created using hash(#) not (//) >> //if p == "X" doesn't work.
if p == "Is Xavier here?": # this is doing an exact match of the string and not finding 'X'
print("X is spotted!")
def tester(p, givenstring = "Too short"):
result=len(p)
if result>=10:
print(p)
else:
print(givenstring)
if 'X' in p: # this will return True if 'X' is present in p
print("X is spotted!")
def main():
while True:
prompt=input("Write something (quit ends): ")
if prompt=="quit":
break
else:
tester(prompt)
main()
Write something (quit ends): This is captain x-merica
This is captain x-merica
Write something (quit ends): This is captain X-merica
This is captain X-merica
X is spotted!
Write something (quit ends): quit
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…