krz, German

Here‘s another interesting , , comparison: „count the number of vowels in a string“. uses an anonymous function as an argument to count(), iterates over the string using list comprehension, does the same but in a vectorized way

orsinium,
@orsinium@fosstodon.org avatar

@krz

Since in bool is essentially an int, you can also do it a bit shorter:

sum(i in 'aeiou' for i in input_str)

nedbat,
@nedbat@hachyderm.io avatar

@orsinium @krz We need to stamp out the "for i" tic.

Wouldn't "for ch in input_str" be better?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • JUstTest
  • tacticalgear
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • ethstaker
  • anitta
  • provamag3
  • Leos
  • cisconetworking
  • megavids
  • lostlight
  • All magazines