About 17,200,000 results
Open links in new tab
  1. Python Checking 4 digits - Stack Overflow

    Nov 6, 2015 · if len(num) == 4 and num.isdigit(): If you really want to use string.digits for whatever reason, a slower approach that uses it correctly would be: if len(num) == 4 and all(c in …

  2. How to Match a Number with a Certain Amount of Digits in Python

    In this article, we show how to match a number with a certain amount of digits in Python using regular expression. Say, we want to match the year in a string. A year is a 4-digit number, …

  3. Check 2 digit or 3 digit positive number in Python | Dremendo

    In this question, we will see how to input a number and check if it is a 2 digit or 3 digit positive number or not in Python programming using the if elif statement. To know more about if elif …

  4. Extracting Digits from an Integer in Python: A Step-by-Step Guide

    Aug 5, 2024 · To extract the nth digit from the right of a number, we can use the following formula: number is the integer from which you want to extract a digit. n is the position of the digit from...

  5. Python – Extract digits from given string - GeeksforGeeks

    Jan 28, 2025 · str.isdigit () method in Python is used to check if all characters in a string are digits. It returns True if all characters are digits (0-9) and there is at least one character otherwise, it …

  6. 2 Easy Ways to Extract Digits from a Python String

    Nov 25, 2020 · In this article, we will be focusing on the ways to extract digits from a Python String. So, let us get started. 1. Making use of isdigit () function to extract digits from a Python …

  7. How to extract and reorder number digits | LabEx

    Learn advanced Python techniques for extracting, manipulating, and reordering number digits with practical code examples and efficient algorithmic approaches.

  8. python - Find the 3rd & 4th digits from a number - Stack Overflow

    Sep 14, 2020 · a = 1234 b = a % 10 #extracts the final digit 4 What about If I wanna extract the 2nd to last digit 3? Similarly for 1 & 2

  9. Python - Find digits in a given Number - Websparrow

    Sep 20, 2023 · Iterate through the digits: Use a loop to iterate through each digit in the string representation of the number. Check for equality: Inside the loop, compare each digit to the …

  10. Solved Write a Python program to accept a number and find

    Here’s the best way to solve it. Python code # ask user to enter a number and read number from us … Not the question you’re looking for? Post any question and get expert help quickly.

  11. Some results have been removed