ThePythonGameBook

learn Python. Create Games

User Tools

Site Tools


en:glossary:a:any

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:glossary:a:any [2020/05/13 10:32]
Horst JENS
en:glossary:a:any [2020/05/13 10:36] (current)
Horst JENS
Line 16: Line 16:
  
 Use any() instead of an expression with a lot of ''​or''​ operators: Use any() instead of an expression with a lot of ''​or''​ operators:
 +
 +<code python;​gutter:​false>​
 +# instead of:
 +coordinate_is_invalid = (x < 0) or (y < 0) or (x > 10) or (y >10)
 +# use any():
 +coordinate_is_invalid = any([x<​0,​y<​0,​ x>10, y>10])
 +</​code> ​
 +</​code>​
  
  
/var/www/horst/thepythongamebook.com/data/pages/en/glossary/a/any.txt ยท Last modified: 2020/05/13 10:36 by Horst JENS