Reputation: 41
I'm getting "invalid syntax" errors pointing to the "in" statement. What's my mistake?
while(notes > 1):
note = choice(scale)
if note[0].isupper() and not in patternNotes:
patternNotes.append(note)
notes -= 1
elif note is not rootNote and note not in patternNotes:
patternNotes.append(note)
notes -= 1
Upvotes: 1
Views: 322
Reputation: 279
Note that this is an infinite loop under certain conditions, like "note in patternNotes". Move the "notes -= 1" statement outside the if/elif and the problem is solved.
Upvotes: 0
Reputation: 82028
It should be note[0].isupper() and note not in patternNotes:
(notice the second note
before not
)
After that your syntax is fine:
i = {}
j = {}
print i is not j and j not in {}
# False
Upvotes: 0
Reputation: 50868
You probably want
if note[0].isupper() and note not in patternNotes:
rather than
if note[0].isupper() and not in patternNotes:
Note the lacking note
in the second one.
Upvotes: 5