Comments on Tips for golfing in Python
Parent
Tips for golfing in Python
If you have any tips for golfing in Python, add them as answers to this post.
Use the unpacking `` instead o …
3y ago
If you print some string `s` w …
3y ago
Reorder expressions in order t …
3y ago
Combine conditionals Python …
3y ago
Replace `n+1` with `-n` and `n …
3y ago
Replace if/else expressions by …
3y ago
Use `a+=[b]` instead of `a.app …
3y ago
` == and` If you want to ch …
3y ago
Combine loops Suppose you h …
3y ago
Replace `range()` if $n …
3y ago
Assign `float`s while leaving …
3y ago
Renaming functions A funny, …
3y ago
Use `lambda`s instead of funct …
3y ago
`import` You can import som …
3y ago
Replace print loops by list un …
3y ago
Replace `for` loops with strin …
3y ago
If you have a loop or `if`, yo …
3y ago
`| == or` This bitwise oper …
3y ago
Post
| == or
This bitwise operator can sometimes be used as the replacement for or
.
a=-2;b=3
if(a>0)|(b>0):print(a+b)
0 comment threads