0

why does this code return a TypeError: 'str' object is not callable TypeError: 'str' object is not callable?

import string

def containsAny(stri, set):
    """Check whether 'str' contains ANY of the chars in 'set'"""
    return 1 in [c in stri for c in set]

a = containsAny("acde",list(string.ascii_uppercase()))

print "{}".format(a)
1
  • 1
    You should rename set to something different (e.g. char_set/iterable/sequence/seq) to avoid shadowing builtin set. Commented Apr 5, 2017 at 12:41

1 Answer 1

1

string.ascii_uppercase is a string, therefore you get an error when trying to call it by adding the ().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.