Python Forum
Filter and str.isdigit producing an error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filter and str.isdigit producing an error
#1
Greetings!
It is probably an elementary problem for you but I'm struggling to understand why the snippet below is failing. Confused
I found it online and it looks ok, but it is not.

s = 'November 11 day' 
pp = int(filter(str.isdigit, s))
print(f" Digits only  -> {pp}")
error:
"int() argument must be a string, a bytes-like object or a number, not 'filter'"

if anyone would explain to me why it errors out...
Thank you!
Reply


Messages In This Thread
Filter and str.isdigit producing an error - by tester_V - Aug-11-2022, 10:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pyautogui.locateOnScreen producing error dude8074 6 3,911 Apr-17-2022, 05:05 PM
Last Post: bowlofred
  producing numbers out of a list bouraque7878 10 3,827 Nov-12-2021, 09:13 PM
Last Post: jefsummers
  Python isdigit() and None samtal 6 8,286 May-06-2021, 05:13 PM
Last Post: Gribouillis
  I don't think my program is producing the correct answer emmapaw24 1 1,749 Mar-31-2020, 01:13 AM
Last Post: stullis
  [Beginner] Code is not producing desired result fakej171 2 2,467 Mar-21-2020, 10:26 AM
Last Post: buran
  user input producing incorrect boolean al_Czervik 4 3,111 Mar-05-2020, 09:50 PM
Last Post: al_Czervik
  str.isdigit() vs str.isnumeric() Skaperen 4 6,352 Jun-14-2019, 01:54 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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