Let me show you the code first.
arr1 = [1,2,3,3,3,3,4,4]
arr2 = []
arr3 = {1:0,2:0,3:0,4:0}
# 1. Add as a list to the set value arr2 except for the overlapping numbers of arr1
arr2 = list(set(arr1))
a = 0
b = 0
c = 0
# 2. Compare the numbers in arr2 with arr1 and add the number of times to the dictionary in arr3 if they overlap
for a in range(len(arr2)):
for b in range(len(arr1)):
if arr2[a] in arr1[b]:
arr3[a+1] += 1
An error appears in the last to second line, 'if arr2[a] in arr1[b]:'.
if arr2[a] in arr1[b]:
TypeError: argument of type 'int' is not iterable
I wonder if arr1 and arr2 are not int type anymore, so even if I print it as int type, it shows up as int, but I'm frustrated why this error appears.
typeerror
The error message TypeError: argument of type 'int' is not usable
is an error caused by the int type (such as list and tuple) where it should be.
There are two variables in the code where the error occurred. The one that should be etherable is the one that is later. In in arr1[b]
, in
must have an (aggregate) enable at the back, and arr1[b]
is just one simple int
integer.
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
611 Uncaught (inpromise) Error on Electron: An object could not be cloned
891 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
600 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.