Nov-20-2018, 02:47 AM
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
|
unsupported operand type(s) for %: 'list' and 'int'
|
|
Nov-20-2018, 02:47 AM
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
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)
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)
May-07-2022, 07:28 AM
(This post was last modified: May-07-2022, 07:28 AM by cool_person.)
nonprimenumbers=[]
primenumbers = []
for i in range (2,100000):
if (i%primenumbers==0):
nonprimenumbers.append
else:
primenumbers.append
print(primenumbers)answer ASAP
May-07-2022, 08:07 AM
Look at your append. You need ()
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags Download my project scripts |
|
|