Feb-04-2017, 12:02 PM
You only want to append error if you didn't find the word in any of the parts of speech. Currently you are appending it for each part of speech it's not in. The standard way to do this is with the break statement, and moving the else clause to be part of the for loop:
for number in sequence: if number % 2: print('Odd number found.') break else: print('No odd numbers found.')The else clause on a for loop executes when the loop exits without a break statement. A good way to think of this is that you are using the for loop to find something. If you find it, you break out of the loop, otherwise you execute the else clause.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures