File tree Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 1
1
## Random Username Generator
2
2
3
3
## Packages needed
4
+
4
5
- requests
5
- - randint
6
+ - random
6
7
7
8
You will need a url with list names in it, next you will have to access the name by the requests, fetch the names to the terminal
8
- Use the randint to randomly pick a name and display it
9
+ Use the random to randomly pick a name and display it
Original file line number Diff line number Diff line change 1
1
import requests
2
- from random import randint
2
+ import random
3
3
4
4
url = 'https://svnweb.freebsd.org/csrg/share/dict/propernames?revision=61766&view=co'
5
5
6
- r = requests .get (url )
7
- text = r .text
8
- # print(text)
6
+ names = requests .get (url ).text
9
7
10
- # We are splitting the words to clear out the empty spaces
11
- individual_word = text .split ()
12
- # print(individual_word)
8
+ # We are splitting the words to clear out the empty spaces and create iterable
9
+ individual_words = names .split ()
13
10
14
- # Next we need it to extract a random name we will use random library
15
- random_number = randint (0 , len (individual_word ))
16
-
17
- # print(individual_word[random_number])
18
-
19
- #to get random word with number
20
- print (individual_word [random_number ] + str (random_number ))
11
+ # to get random word
12
+ print (random .choice (individual_words ))
You can’t perform that action at this time.
0 commit comments