Mar-05-2019, 05:38 PM
(Mar-05-2019, 11:21 AM)perfringo Wrote: One word of caution about using str.isnumeric. Documentation states:" Return true if all characters in the string are numeric characters, and there is at least one character, false otherwise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric." In real life scenarios .isnumeric() is not sufficient to determine whether user input can be converted to int or not. Following is expected behaviour:What alternative would you recommend?>>> '1234567890²'.isnumeric() True >>> int('1234567890²') + 2 /../ ValueError: invalid literal for int() with base 10: '1234567890²'