python - "Function object is unsubscriptable" in basic integer to string mapping function -


I am trying to write a function to return the string of any number less than 1000.

Every time I run my code at the interactive prompt, I have to work without any problems, but when I try to import the word and run it with more than 20 test numbers , Then it fails because "TypeError: 'function does not cancel the object.'>

Depending on the error message, it seems that this issue occurs when the index tries to numbering (e.g. Of Is trying to extract the number 4 in the case of test = n = 24) and the compiler thinks that numstring is a function instead of wire because the first line of the function defines numstring as the string of variable digits Not really sure why this happens.

Any help in getting around this error, or even explain why I am seeing it, it will be horrible.

  def wordify (n): in the string # n To parse out tens and hundreds later, NumString = str (n) is less hard-coded than # N20. If n & lt; 21: 21 and 99 points between nick and nanododmarkmark (n) Return N # and then insert. Eleph N & LT; 100: onesNum = numString [-1] ones = numToWordMap (int (onesNum)) tensNum = num string [-2] tens = numToWordMap (int (tensNum) * 10) return tones + and others: # toDO def numToWordMap (num) 5: "five", 6: "six", 7: "seven": mapping = {0: "", 1: "one", 2: "two", 3: "three", 4: "four" , 8: "eight", 9: "nine", 10: "ten", 11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen", 16 , "Seventeen", 17: "seventy", 18: "eighteen", 19: "nineteen", 20: "twenty", 30: "thirty", 40: "fourth", 50: "fifty", 60: 200: "two hundred", 600: "three hundred", 400: "four hundredth," 500: "five hundred", "seventy", 80: "eighty", 90: "ninety", 100: "one hundred" "Six hundred", 700: "seven hundred", 800: "The eighth "900": "hundred hundred",} return map [number] if __name__ == '__main__': pass  

An error means that the function was used, where there should be a list, such as:

  wordify (40)  

back "fourth" I write it to "forty" and you do not have any entry for zero


Comments

Post a Comment

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -