Nov-20-2018, 02:47 AM
Nov-20-2018, 03:02 AM
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)
Feb-22-2022, 02:19 AM
to get your list:
for numeric:
for numeric:
a = list(num for num in range (0, 11)) print(a)
Output:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
a = list(str(num) for num in range (0, 11)) print(a)
Output:['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
May-07-2022, 07:28 AM
nonprimenumbers=[] primenumbers = [] for i in range (2,100000): if (i%primenumbers==0): nonprimenumbers.append else: primenumbers.append print(primenumbers)
Output:Traceback (most recent call last):
File "main.py", line 8, in <module>
if (i % primenumbers == 0):
TypeError: unsupported operand type(s) for %: 'int' and 'list'
answer ASAPMay-07-2022, 08:07 AM
Look at your append. You need ()