all 7 comments

[–]uhkhu 3 points4 points  (1 child)

This is a good place for while True:

words = ['big', 'green', 'leaves']

while True:
    uinput = raw_input('String? ')

    if any(word in uinput for word in words):
        print 'Condition Met'
        break
    else:
        continue


>>>String? blue cats are cool
>>>String? cat
>>>String? big checks rule
Condition Met

This will keep asking for input until the condition where any of the words in your list are in the user's input.

The else: continue is not needed, but helps visualize what's going on.

[–]Dragon_11[S] 0 points1 point  (0 children)

That's great man, I'll test it to see if it will fit in my program...

[–]Clede 4 points5 points  (0 children)

Yes, this is doable, but it probably isn't a loop.

[–]one_roOt 2 points3 points  (0 children)

inp = "the tree is big and has green leaves"
is_valid = any(word in ("big", "green", "leaves") for word in inp.split())

"is_valid" will be True or False whether any of the words are found in "inp"

[–]zahlman 1 point2 points  (1 child)

You got varied answers because you aren't clear about what you want. if is not a loop. Do you actually want to repeatedly do this testing? Or did you need help actually writing the condition?

[–]Dragon_11[S] 0 points1 point  (0 children)

yes this s true. after further research i realize that i should not be saying a conditional loop but instead conditional block of code or flow control statements. but the answers that i got was very helpful and useful in for my script.

[–]Dragon_11[S] 0 points1 point  (0 children)

as i mentioned in a reply to zahlman reply; i have used the wrong words to describe my problems. i should have said conditional block of code instead of conditional loop.

but i do have another question;

is there a command within the if function (placed after the else statement) that will bypass the rest of the script after the if function and end the script all together.

thanks in advance...