Skip to content

Commit 2e33624

Browse files
authored
Resolved index out of range error
fixed index out of range error for tuple and added another special character feature into generated passwords
1 parent 9cd0844 commit 2e33624

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

passwordGenerator.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
# PasswordGenerator GGearing314 01/10/19
2-
from random import *
1+
# PasswordGenerator GGearing 314 01/10/19
2+
# modified Prince Gangurde 4/4/2020
3+
4+
from random import randint
35

46
case = randint(1, 2)
57
number = randint(1, 99)
8+
9+
specialCharacters = ( "!", "@", "#", "$", "%", "/", "?", ":" , "<", ">", "|" , "&", "*", "-", "=", "+", "_")
10+
611
animals = (
712
"ant", "alligator", "baboon", "badger", "barb", "bat", "beagle", "bear", "beaver", "bird", "bison", "bombay", "bongo",
813
"booby", "butterfly", "bee", "camel", "cat", "caterpillar", "catfish", "cheetah", "chicken", "chipmunk", "cow", "crab",
914
"deer", "dingo", "dodo", "dog", "dolphin", "donkey", "duck", "eagle", "earwig", "elephant", "emu", "falcon", "ferret",
1015
"fish", "flamingo", "fly", "fox", "frog", "gecko", "gibbon", "giraffe", "goat", "goose", "gorilla")
16+
1117
colour = (
1218
"red", "orange", "yellow", "green", "blue", "indigo", "violet", "purple", "magenta", "cyan", "pink", "brown", "white",
1319
"grey", "black")
14-
chosenanimal = animals[randint(0, len(animals))]
15-
chosencolour = colour[randint(0, len(colour))]
20+
21+
chosenanimal = animals[randint(0, len(animals) - 1)] # randint will return max lenght but , tuple has index from 0 to len-1
22+
chosencolour = colour[randint(0, len(colour) - 1)]
23+
chosenSpecialCharacter = specialCharacters[randint(0, len(specialCharacters) - 1)]
24+
1625
if case == 1:
1726
chosenanimal = chosenanimal.upper()
18-
print(chosencolour, number, chosenanimal)
27+
print(chosencolour, number , chosenanimal, chosenSpecialCharacter)
1928
else:
2029
chosencolour = chosencolour.upper()
21-
print(chosenanimal, number, chosencolour)
22-
# print("This program has exatly ",(len(animals)*len(colour)*99*2),"different combinations") #I'm not sure this is right
23-
input("Press enter to close...")
30+
print(chosenanimal, number, chosencolour, chosenSpecialCharacter)

0 commit comments

Comments
 (0)