0
I have a code that is returning me the following error
AttributeError: 'int' object has no attribute 'count'...
I have a list of multiple numbers, and I need to know how many repeat numbers from 1 to 13. The code below is just a small example to then transpose all this into something bigger.
#!/usr/bin/env python3
number_sequence = [
16, 19, 1, 3, 8, 11, 18, 21, 13, 9, 24, 5, 23, 10, 6, 22, 19, 25, 3,
2, 21, 20, 23, 24, 18, 9, 4, 6, 8, 15, 16, 22, 5, 25, 11, 14, 9, 4,
13, 17, 15, 3, 10, 8, 6, 10, 15, 19, 7, 9, 8, 20, 22, 16, 4, 18, 1,
11, 5, 21, 19, 1, 25, 7, 20, 22, 13, 8, 3, 17, 2, 15, 14, 12, 18, 18,
25, 12, 8, 20, 24, 22, 4, 11, 14, 3, 23, 15, 10, 21, 10, 1, 4, 25,
19, 7, 22, 11, 9, 23, 17, 14, 13, 18, 3, 7, 6, 23, 14, 1, 19, 8, 5,
11, 25, 9, 16, 4, 17, 21, 7, 20, 6, 5, 21, 1, 17, 12, 16, 24, 3,
23, 22, 4, 18, 1, 12, 4, 18, 7, 20, 11, 10, 2, 25, 14, 21, 6, 19, 23
]
for n in range(1, 14):
print(n.count(number_sequence))
I do not understand why this error since if I run only one occurrence at a time it works right without any error.
For example: print(sequence_numbers.count(5))
n.count(number_sequence)
, you reversed. The correct is:number_sequence.count(n)
– Woss
Problem solved, thank you very much Anderson Carlos Woss... I’ll get good at it yet, rsrsr. The mistake was so silly that not you believe...
– Claudinei Miller