Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python random phone number

import random

def phn():
    n = '0000000000'
    while '9' in n[3:6] or n[3:6]=='000' or n[6]==n[7]==n[8]==n[9]:
        n = str(random.randint(10**9, 10**10-1))
    return n[:3] + '-' + n[3:6] + '-' + n[6:]
Comment

create random phone number python

# import module
import random as r
  
ph_no = []
  
# the first number should be in the range of 6 to 9
ph_no.append(r.randint(6, 9))
  
# the for loop is used to append the other 9 numbers.
# the other 9 numbers can be in the range of 0 to 9.
for i in range(1, 10):
    ph_no.append(r.randint(0, 9))
  
# printing the number
for i in ph_no:
    print(i, end="")
Comment

PREVIOUS NEXT
Code Example
Python :: drop rows in list pandas 
Python :: flask define template folder 
Python :: import data in pandad 
Python :: unique words from pandas 
Python :: hide particular attribute in django admin 
Python :: django datetimefield default 
Python :: mean class accuracy sklearn 
Python :: python for each attribute in object 
Python :: list of characters python 
Python :: suppress warning jupyter notebook 
Python :: flask for loops 
Python :: take off character in python string 
Python :: exclude columns in df 
Python :: python yaml parser 
Python :: concat dictionary of dataframes 
Python :: resize numpy array image 
Python :: pygame event mouse right click 
Python :: rotational list python 
Python :: python dict order a dict by key 
Python :: python print exception 
Python :: one line input in python 
Python :: argparse multiple arguments as list 
Python :: django.core.exceptions.FieldError: Unknown field(s) (author) specified for Comment 
Python :: make csv lowercase python 
Python :: spacy matcher syntax 
Python :: docker pyinstaller windowa 
Python :: python rickroll code 
Python :: ec2 upgrade python 3.7 to 3.8 
Python :: boto3 with aws profile 
Python :: python read excel sheet name 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =