In Python3 string.digits
— it is a pre-initialized string used as a string constant. In Python, string.digits
will produce lowercase letters "0123456789".
Syntax: string.digits
Parameters: Doesn’t take any parameter, since it’s not a function.
Returns: Return all digit letters.
Note. Make sure to import the string library function to use string.digits
Code # 1:
|
Output:
0123456789
Code # 2: this code checks if there are only numbers in the input line
|
Exit:
0123 456 789 -" False 12.0124 -" False 12345 -" True
Applications:
Digits string constants can be used in many practical applications.Let’s see the code, explain See how to use numbers to generate strong random passwords of a given size.
generate_pass = ’ ’.join ([random.choice (string.ascii_uppercase +
| tr>
Exit :
2R8gaoDKqn