Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,894 questions

51,825 answers

573 users

How to generate 4 digit int random number in Python

2 Answers

0 votes
from random import randint

for i in range(1, 10):
    print(randint(1000, 9999))


'''
run:

6207
1779
6725
3809
9165
8076
3131
8785
8137

'''

 



answered Apr 27, 2016 by avibootz
0 votes
import random

for i in range(1, 10):
    print(random.choice(range(1000, 9999)))


'''
run:

1022
3022
5595
1758
6917
8420
4901
6799
7722

 



answered Apr 27, 2016 by avibootz

Related questions

1 answer 148 views
1 answer 116 views
1 answer 137 views
1 answer 273 views
1 answer 183 views
...