Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
blank space + input()
#5
(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:
 >>> '1234567890²'.isnumeric() True >>> int('1234567890²') + 2 /../ ValueError: invalid literal for int() with base 10: '1234567890²' 
What alternative would you recommend?
Reply


Messages In This Thread
blank space + input() - by ClassicalSoul - Mar-05-2019, 02:15 AM
RE: blank space + input() - by Larz60+ - Mar-05-2019, 02:39 AM
RE: blank space + input() - by ichabod801 - Mar-05-2019, 02:41 AM
RE: blank space + input() - by perfringo - Mar-05-2019, 11:21 AM
RE: blank space + input() - by ClassicalSoul - Mar-05-2019, 05:38 PM
RE: blank space + input() - by ichabod801 - Mar-05-2019, 06:39 PM
RE: blank space + input() - by perfringo - Mar-06-2019, 09:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  from global space to local space Skaperen 4 2,375 Sep-08-2020, 04:59 PM
Last Post: Skaperen
  Verify input as integer and not blank GMCobraz 3 2,177 Jun-22-2020, 02:47 PM
Last Post: pyzyx3qwerty
  CSV gives me blank row on PC, but not a Mac bazcurtis 2 2,855 Jan-06-2020, 08:40 AM
Last Post: buran
  How to recognize space or enter as one-character input? Mark17 5 5,722 Oct-17-2019, 08:19 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020