# take string
      string = "2 Java developer and 5 Python developer"
      # print original string
      print("The original string:", string)
      # using str.split() + isdigit()
      num = []
      for i in string.split():
          if i.isdigit():
              num.append(int(i))
      # print extract numbers
      print("Extract Numbers:", num)
      
      Python language logo

      number extractor

      beginner
      strings
      numbers

      Python program to extract number from string

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.