unsupported operand type(s) for %: 'list' and 'int' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: unsupported operand type(s) for %: 'list' and 'int' (/thread-14210.html) |
unsupported operand type(s) for %: 'list' and 'int' - RandomCoder - Nov-20-2018 a = [] k=1 for x in range(0,10): a.append(int(input())) for x in range(0,30): if (a%2==0): k=k*a print(k)need answer ASAP RE: unsupported operand type(s) for %: 'list' and 'int' - stullis - Nov-20-2018 Because "a" is a list, you cannot simply perform mathematics with it. You can iterate over "a" and take the modulus of each number in it: a = [] k=1 for x in range(0,10): a.append(int(input())) for x in a: if (x % 2 == 0): k *= x print(k) RE: unsupported operand type(s) for %: 'list' and 'int' - Larz60+ - Feb-22-2022 to get your list: for numeric: a = list(num for num in range (0, 11)) print(a)
a = list(str(num) for num in range (0, 11)) print(a)
RE: unsupported operand type(s) for %: 'list' and 'int' - cool_person - May-07-2022 nonprimenumbers=[] primenumbers = [] for i in range (2,100000): if (i%primenumbers==0): nonprimenumbers.append else: primenumbers.append print(primenumbers) answer ASAP
RE: unsupported operand type(s) for %: 'list' and 'int' - menator01 - May-07-2022 Look at your append. You need () |