daniel
daniel

Reputation: 73

I'm looking for a function that is like 'str.isupper()' but with symbols?

I'm looking for a function that can do the exact same like str.isupper() but instead with symbols like:

symbols = '!@#$%^&*()-_+=`~;:\'[]{}|<>,./?'

foo = '@&(='

# and then a function somewhat like this

print(issymbol(foo)) # this should return true

Thanks!

Upvotes: 0

Views: 74

Answers (1)

Prune
Prune

Reputation: 77857

For a single char, this is simply the in operator:

print( char in symbols )

For a string, use the all method:

print (all (char in symbols for char in foo) )

Upvotes: 2

Related Questions