Python throws the error, ‘tuple’ object is not callable, when you forget to separate members using comma in single or multidimensional tuples.

Consider this example –

myTuple = (
    ("Captain America", "Shield")
    ("Ironman", "Suit")
    ("Thor", "Mjolnir")
    ("Hawkeye", "Bow-arrows")
    ("Spiderman", "Web Shooters")
)

print(myTuple)
# Error: 'tuple' object is not callable

This code will throw the tuple object not callable error because although we put commas in 2nd dimensional elements like ("Captain America", "Shield") we forgot to put one in 1st dimension like ("Captain America", "Shield") , ("Ironman", "Suit").

The correct way to write this code is –

myTuple = (
    ("Captain America", "Shield"),
    ("Ironman", "Suit"),
    ("Thor", "Mjolnir"),
    ("Hawkeye", "Bow-arrows"),
    ("Spiderman", "Web Shooters")
)

print(myTuple)

    Tweet this to help others

Live Demo

Demo might not work in private window (incognito)

Comments

About the Author

akamit

I am Akash Mittal, an overall computer scientist. If you want to guest post, need help in your projects, want to advertise, Feel free to contact me at [email protected]

View All Articles