Problem: Order of operations with a list

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

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
participants (2)
-
Julien Palard
-
MrSiuol Siuol