The class Item has a member function text() that returns a list of strings.
The class Dictionary has a member function items() that returns a list of Items.
dict is an instance of Dictionary.
I want to test if all characters in all strings in all items in dict are ASCII.
I tried
all(ord(ch) < 128 for ch in s for s in item.text() for item in dict.items())
This gives the error message “global name ‘s’ not defined”.
What is the correct way?
The order of the
forclauses needs to be the other way around. The innermost loop comes last, the outmost loop comes first.