Feb-08-2019, 03:36 AM
Your code has a number of problems. First, do not use 'is' for equality. The is operator tests identity, not equality. That is, are these the same object, not are these equivalent objects. Use the equality operator (==).
Second, you are using 'or' incorrectly. This:
Second, you are using 'or' incorrectly. This:
if random.choice(an) == 'hate' or 'love':is equivalent to:
if (random.choice(an) == 'hate') or 'love':Due to order of operations. Non-empty strings like 'love' are treated as True in conditional expressions. So line 2 of your code will always be True, and will always trigger. The correct way to test multiple equalities like this is the 'in' operator:
if random.choice(an) in ('hate', 'love'):
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