About 1,010,000 results
Open links in new tab
  1. Python Four Digits Counter - Stack Overflow

    Mar 10, 2011 · How do we use python to generate a four digit counter? range(0,9999) will have 1 digits, 2 digits and 3 digits. We only want 4 digits. i.e. 0000 to 9999. Of course, the simplest …

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

    Aug 5, 2024 · Extracting digits from an integer in Python can be accomplished efficiently using a combination of modulo and integer division. By mastering the formula: digit = (number % 10 **...

  3. Python Checking 4 digits - Stack Overflow

    Nov 6, 2015 · import string import math def fourDigit (): num = raw_input ("Enter a 4 digit number: ") if (len (num) == 4 and string.digits == True): some = int (int (val [1]) + int (val [3])) pr...

  4. How to take the nth digit of a number in python

    Sep 23, 2016 · Simply use number // 10**n % 10 as this answer suggests: stackoverflow.com/a/39644726/7339624. This solution solves many more "digit of a number" …

  5. Python regex for int with at least 4 digits - Stack Overflow

    May 2, 2013 · I've got a string from which I want to extract an int with at least 4 digits and at most 7 digits. I tried it as follows: >>> import re >>> teststring = 'abcd123efg123456' >>> …

  6. python - How to validate an input with a 4-digit number

    Before casting the user's input into an integer, you can check to see if their input has 4 digits in it by using the len function: However, when using the int function, Python turns "0007" into …

  7. How can I print an integer number displaying 4 decimal digits?

    Jul 28, 2014 · Format your number using format(): format(mas[i], '.4f') This formats numbers (including integers) to 4 decimal places. See the Format Specification Mini-Language …

  8. Python – Extract digits from given string - GeeksforGeeks

    Jan 28, 2025 · Using re.findall () in Python allows to extract all substrings that match a specific pattern such as digits, from a given string. Explanation: re.findall () function is used to find all …

  9. How to Generate Random 4-Digit Numbers in Python? - Python

    Jan 10, 2025 · Python’s built-in random module provides several functions to generate random numbers. Let’s explore how to use it to create random 4-digit numbers. 1. Basic Random …

  10. 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.

Refresh