python - Getting can't convert int to str error in my code can't figure out why -


my code supposed take pin number , change "easy remember" arrangement of vowels , consonants

def alphapinencode(pin):     vowels = "aeiou "     consonants = "bcdfghjklmnpqrstvwyz "     alphapin = " "     while pin > 0:         newpin = pin // 100         pinremain = pin % 100         voweltofind = pinremain % 5         pinvowel = vowels.find(voweltofind)         pinconsonant = consonants.find(pinremain // 5)         pin = newpin         alphapin = alphapin + pinvowel + pinconsonant      return alphapin 

any appreciated, thanks!

i believe issue these 2 lines:

voweltofind = pinremain % 5 pinvowel = vowels.find(voweltofind) 

in case voweltofind integer, , vowels string. find method of str accepts string argument, , returns position in string - passing integer instead. aren't looking find substring within vowels, looking retrieve character @ index voweltofind. believe ought following instead:

voweltofind = pinremain % 5 pinvowel = vowels[voweltofind] 

note

i'm solving specific "int str" error asked about. i'm not sure rest of logic you're using generate "easy-to-remember" character sequence.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -