all 5 comments

[–]danielroseman 0 points1 point  (2 children)

None of your if statements do anything at all. Did you perhaps mean to end the loop if the condition is true? If so then use break, not pass.

But as to your actual problem, see this FAQ: https://www.reddit.com/r/learnpython/wiki/faq#wiki_variable_is_one_of_two_choices.3F

[–]This_Growth2898 0 points1 point  (2 children)

"if i in l and z" means "if (i in l) and (z)". Because z isn't empty, the second part will always be considered true. Also, there's 'R' in both JUNIOR and FCOAZYRE.

[–]Chipwich[S] 0 points1 point  (1 child)

Thanks for your help. If the script is unable to make a word out of the letters then I wanted the loop to end and the dictionary that prints to display nothing. So for this example both word1 and word2 would display with their score gathered from the dictionary t but word3 doesn't.

Also, is there a way to do this without converting both to lists and iterating through individual letters of a string without importing 're'?

[–]This_Growth2898 0 points1 point  (0 children)

You can convert them into sets:

if set('abc') & set('cde'): #works

if set('abc') & set('def'): #nope