Reputation: 3
I'm trying to turn a string into lowercase and then count the amount of times a letter appears in that string using Python.
Am I allowed to combine both string functions together? Or is this frowned upon or completely wrong because it does seem to work fine:
name2 = name1.lower().count("a")
Upvotes: 0
Views: 91
Reputation: 74
Yes you may chain several calls together in the manner you mentioned. It is both syntactically correct and Pythonic (conforms to normal conventions of using the Python language.)
Upvotes: 2