[docs] Problem: Order of operations with a list

Julien Palard julien at palard.fr
Mon Mar 11 18:02:20 EDT 2019


Hi MrSiuol,

> There is a problem with: [0]*4/2
>
> "Traceback (most recent call last):
>   File "<pyshell#5>", line 1, in <module>
>     [0]*4/2
> TypeError: unsupported operand type(s) for /: 'list' and 'int'"
>
> Solution: prioritize calcul without list, before duplicate list

Did you find [0]*4/2 in the documentation? I can't find it (this is a mailing list about documentation, to report bugs about the language please use https://bugs.python.org).

A good solution for your problem would be: `[0] * int(4 / 2)`, assuming either 4 or 2 are variables in your code, else just write `[0, 0]` :)

Bests,
-- 
Julien Palard
https://mdk.fr



More information about the docs mailing list