Python Forum
unsupported operand type(s) for %: 'list' and 'int'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unsupported operand type(s) for %: 'list' and 'int'
#2
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)
BashBedlam likes this post
Reply


Messages In This Thread
RE: unsupported operand type(s) for %: 'list' and 'int' - by stullis - Nov-20-2018, 03:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Type Error: Unsupported Operand jhancock 2 1,301 Jul-22-2023, 11:33 PM
Last Post: jhancock
  search a list or tuple for a specific type ot class Skaperen 8 2,009 Jul-22-2022, 10:29 PM
Last Post: Skaperen
  TypeError: unsupported operand type(s) for +: 'dict' and 'int' nick12341234 1 9,416 Jul-15-2022, 04:04 AM
Last Post: ndc85430
  TypeError: unsupported opperand type(s) for %: 'int' and 'list' cool_person 7 2,268 May-07-2022, 08:40 AM
Last Post: ibreeden
  You have any idea, how fix TypeError: unhashable type: 'list' lsepolis123 2 3,093 Jun-02-2021, 07:55 AM
Last Post: supuflounder
  unsupported operand type(s) for /: 'str' and 'int' Error for boxplot soft 1 3,109 Feb-09-2021, 05:40 PM
Last Post: soft
  What type of *data* is the name of a list/tuple/dict, etc? alloydog 9 4,467 Jan-30-2021, 07:11 AM
Last Post: alloydog
Question dict value, how to change type from int to list? swissjoker 3 2,802 Dec-09-2020, 09:50 AM
Last Post: perfringo
  unsupported operandtype(s) for -: 'list' and 'int' Lakkad 2 3,633 Apr-27-2020, 10:16 AM
Last Post: pyzyx3qwerty
  calculate_bai -- TypeError: unsupported operand type(s) for *: 'float' and 'NoneType' pantherd 1 3,286 Apr-21-2020, 12:31 PM
Last Post: anbu23

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020