Python Forum
Error in the method "count" for tuple
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in the method "count" for tuple
#1
I just wrote this simple code to count the number of 1 in this tuple. Ironically, it returns 2 instead of 1. I have the last version of Python. Also, I checked the program with Colab, and I got the same wrong result. It is interesting that this problem occurs only for "1"!!

mixed_tuple = (1, 3.4, "ali", True, [0, 3, 3])
print(mixed_tuple.count(1))
The result will be 2.
Reply


Messages In This Thread
Error in the method "count" for tuple - by fff - Nov-23-2024, 01:15 PM
RE: Error in the method "count" for tuple - by fff - Nov-24-2024, 03:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strange argument count error rowan_bradley 3 1,684 Aug-06-2023, 10:58 AM
Last Post: rowan_bradley
  Row Count and coloumn count Yegor123 4 2,642 Oct-18-2022, 03:52 AM
Last Post: Yegor123
  List of error codes to find (and count) in all files in a directory tester_V 8 5,190 Dec-11-2020, 07:07 PM
Last Post: tester_V
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 4,325 Nov-04-2020, 11:26 AM
Last Post: Aggam
  Python Error- TypeError: ('Params must be in a list, tuple, or Row', 'HY000') DarkCoder2020 3 7,142 Jul-29-2020, 12:02 AM
Last Post: Larz60+
  Error: Nested method ? JohnnyCoffee 5 3,791 May-03-2020, 02:43 PM
Last Post: JohnnyCoffee
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 4,324 May-21-2019, 11:39 AM
Last Post: avorane
  Error while fetching data from PostgreSQL tuple indices must be integers or slices, n Sandy777 6 7,664 May-12-2019, 11:41 AM
Last Post: Sandy777
  Type error when reading in different data types on an __init__ method Dylanmull 3 3,673 May-09-2019, 02:05 PM
Last Post: buran
  Getting error when called through instance method aankrose 2 3,342 Mar-02-2019, 07:19 PM
Last Post: aankrose

Forum Jump:

User Panel Messages

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