@Schal330@lemmy.world to Programmer Humor@programming.dev • 8 months agoIt must be a silent Rlemmy.worldimagemessage-square120fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1imageIt must be a silent Rlemmy.world@Schal330@lemmy.world to Programmer Humor@programming.dev • 8 months agomessage-square120fedilink
minus-square@cypherix93@lemmy.worldlinkfedilinkEnglish0•8 months ago"strawberry".split('').filter(c => c === 'r').length
minus-square@SpaceNoodle@lemmy.worldlinkfedilink0•8 months agolen([c if c == ‘r’ for c in “strawberry”])
minus-square@MrLLM@ani.sociallinkfedilinkEnglish0•8 months agoimport re; r = [c for c in re.findall("r", "strawberry")]; r = "".join(r); len(r)
minus-squareAwkwardLookMonkeyPuppetlinkfedilinkEnglish0•8 months agoAre you implying that it’s running a function on the word and then giving a length value for a zero indexed array?
minus-square@Sluyter548@lemmy.worldlinkfedilink0•8 months agoA zero indexed array doesn’t have a different length ;)
"strawberry".split('').filter(c => c === 'r').length
'strawberry'.match(/r/ig).length
len([c if c == ‘r’ for c in “strawberry”])
import re; r = [c for c in re.findall("r", "strawberry")]; r = "".join(r); len(r)
(\r (frequencies “strawberry”))
Are you implying that it’s running a function on the word and then giving a length value for a zero indexed array?
A zero indexed array doesn’t have a different length ;)