python - converted letters to number now convert to three letters over and over -


i've got code

letters = input('write text: ') letters = letters.lower() numberen = [] car=["c","a","r"] caren=[] character in letters:     number = ord(character) - 96     numberen.append(number)  number in numberen:     en = (numberen)     en = (numberen(car))     print (en) 

what tried change hi [8,9] did work change ca e.g.

hi [8,9] ca/[c,a] 

that didn't work tried change string

base = ord('a') - 1  def str_to_nums(s):     return [ord(ch) - base ch in s]  def nums_to_str(nums):     return "".join(chr(n + base) n in nums)  print(str_to_nums("hi"))    # => [8, 9] print(nums_to_str([8, 9]))  # => "hi"  print(str_to_nums("ca"))    # => [3, 1] print(nums_to_str([3, 1]))  # => "ca" 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -