This is an indentation error. The if statements that print the password at the end are inside the symbol_want if statement. You need to unindent the print statements by one level, and it will work fine.
import random
def password():
normal_adjectives = ['Funny', 'Amazing', 'Infinity', 'Fabulous', 'Red', 'Rainbow', 'Adorable', 'Adventurous', 'Impressive', 'Determined',
'Delighted', 'Scary', 'Active', 'Distinct', 'Eager', 'Elegant', 'Excited', 'Enchanted', 'Fair', 'Fierce', 'Fancy',
'Gentle', 'Glamorous', 'Graceful', 'Happy', 'Handsome', 'Hungry', 'Fluffy', 'Important', 'Itchy', 'Impossible',
'Jealous', 'Joyous', 'Jolly', 'Kind', 'Caring', 'Lazy', 'Lonely', 'Lucky', 'Lovely', 'Magnificent', 'Modern',
'Mysterious', 'Naughty', 'Nervous', 'Nice', 'Obnoxious', 'Outrageous', 'Outstanding', 'Perfect', 'Pleasant',
'Powerful', 'Precious', 'Proud', 'Real', 'Rich', 'Smily', 'Sleepy', 'Sore', 'Sparkling', 'Splendid',
'Stormy', 'Strange', 'Super', 'Talented', 'Tense', 'Tender', 'Terrible', 'Thankful', 'Thoughtful',
'Tired', 'Tough', 'Troubled', 'Unusual', 'Vast', 'Victorious', 'Vicious', 'Slick', 'Weary', 'Wicked',
'Wild', 'Worried', 'Zealous', 'Orange', 'Yellow', 'Green', 'Blue', 'Pink', 'Purple', 'Indigo', 'Violet',
'Affectionate', 'Stubborn', 'Confused', 'Sticky', 'Slimy', 'Hairless', 'Hairy']
normal_nouns = ['Cheetah', 'Book', 'Chair', 'Pigeon', 'Dolphin', 'Actor', 'Animal', 'Apple', 'Balloon', 'Banana', 'Battery',
'Bed', 'Boy', 'Branch', 'Car', 'Candle', 'Carpet', 'Crayon', 'Diamond', 'Dream', 'Dress', 'Egg', 'Eggplant',
'Elephant', 'Eye', 'Fish', 'Forest', 'Football', 'Fountain', 'Garage', 'Gold', 'Grass', 'Guitar', 'Hamburger',
'Helmet', 'Horse', 'Penguin', 'Honey', 'Ice', 'Insect', 'Iron', 'Jelly', 'Juice', 'Kangaroo', 'Kite', 'Knife',
'Lamp', 'Lion', 'Lizard', 'Lunch', 'Magazine', 'Monkey', 'Microphone', 'Nail', 'Needle', 'Notebook', 'Ocean',
'Oil', 'Oyster', 'Ghost', 'Parrot', 'Piano', 'Pizza', 'Pillow', 'Planet', 'Queen', 'Rainbow', 'Restaurant',
'River', 'Rose', 'Sandwich', 'Shampoo', 'Sugar', 'Stone', 'Spoon', 'Shoe', 'Phone', 'Telephone', 'Television',
'Tent', 'Tomato', 'Toothbrush', 'Train', 'Truck', 'Umbrella', 'Vase', 'Vegetable', 'Vulture', 'Wall', 'Whale',
'Wizard', 'Window', 'Wire', 'Xylophone', 'Yacht', 'Zebra', 'Glass', 'Gas', 'Budgie', 'Snake', 'Chimpanzee']
funny_adjectives = ['Hairy', 'Crazy', 'Hysterical', 'Funny', 'Feisty', 'Chunky', 'Fluffy', 'Hungry', 'Itchy', 'Jolly',
'Modern', 'Naughty', 'Obnoxious', 'Outrageous', 'Smily', 'Troubled', 'Wild', 'Brown', 'Hairless',
'Slimy', 'Sticky', 'Confused', 'Stubborn', 'Idiotic', 'Affectionate', 'Determined', 'Feeble'
'Flying', 'Helpless', 'Hopeful', 'Dead']
funny_nouns = ['Monkey', 'Toaster', 'Lettuce', 'Kitty', 'ElasticBand', 'Arms', 'Legs', 'ToiletSeat', 'DeathWish',
'Pigeon', 'Egg', 'Grass', 'Hamburger', 'Shampoo', 'Door', 'Wall', 'FishEye', 'FluffBall', 'Sardine',
'Blubber', 'Gargoyle', 'Goggles', 'Hedge', 'Shrub', 'Squelch', 'Donkey', 'Pepper']
animal_adjectives = ['Flying', 'Epic', 'Hissing', 'Swift', 'Fast', 'Amazing', 'Growling', 'Snarling', 'Frisky',
'Amphibious', 'Exotic', 'Feral', 'Wild', 'Dead', 'Scary', 'Fluffy', 'Domestic', 'Tame',
'Vicious', 'Graceful', 'Predatory', 'Aquatic', 'Screeching', 'Adorable']
animal_nouns = ['Cat', 'Snake', 'Dog', 'Monkey', 'Budgie', 'Bird', 'Ant', 'Anteater', 'Fish', 'Sardine', 'Chimpanzee',
'Clownfish', 'Lionfish', 'Bear', 'Lion', 'Tiger', 'Elephant', 'Hippo', 'Rhinoceros', 'Frog', 'Wolf',
'Buffalo', 'Eagle', 'Hawk', 'Albatross', 'Lynx', 'PolarBear', 'Snowcat', 'Lizard', 'Crocodile',
'Alligator', 'Parrot', 'Badger', 'Beaver', 'Crow', 'Squirrel', 'Dragon', 'Cheetah', 'Pigeon',
'Dolphin', 'Kangaroo', 'Fly', 'Insect', 'Horse', 'Penguin', 'Squid', 'Octopus', 'Vulture',
'Zebra', 'Kitten', 'Donkey', 'Antelope', 'Echidna', 'Pelican', 'Baboon', 'Bee', 'Swan', 'Tapir',
'Hyena', 'Lemur', 'Pig', 'Cow', 'Sheep', 'Camel', 'Giraffe', 'Cobra', 'Crab', 'Crane', 'Dingo',
'Fox', 'Dove', 'JayBird', 'Owl', 'Hedgehog', 'Elk', 'Emu', 'Falcon', 'Turtle', 'Hornet', 'Wasp',
'Ibis', 'Jackal', 'Koala']
landmarks_adjectives = ['Tall', 'Sparkling', 'Dazzling', 'White', 'Sandy', 'Rocky', 'Big', 'Large', 'Golden', 'Amazing',
'Inccredible']
landmarks_nouns = ['EiffelTower', 'TowerOfPisa', 'Colosseum', 'WhiteHouse', 'TajMahal', 'WallOfChina', 'StatueOfLiberty',
'PyramidOfGiza', 'Uluru', 'OperaHouse', 'ParliamentHouse', 'LondonEye', 'Stonehenge',
'GoldenGateBridge']
food_adjectives = ['Delicious', 'Juicy', 'Luxurious', 'Warm', 'Salty', 'Spicy', 'Flavoursome', 'Bitter', 'Enjoyable',
'Delectable', 'Crunchy', 'Sweet', 'Sour', 'Savoury', 'Divine', 'Fruity', 'Appetising', 'Heavenly',
'Hot', 'Lush', 'Mouthwatering', 'Incredible', 'Horrid', 'Peppery', 'Pungent', 'Pleasant',
'Rich', 'Scrumptious', 'Sharp', 'Strong', 'Succulent', 'Sugary', 'Saline', 'Tasteless', 'Tasty',
'Yummy']
food_nouns = ['Apple', 'Banana', 'Hamburger', 'Burger', 'Cheeseburger', 'Strawberry', 'Steak', 'Pasta', 'Mince',
'Fry', 'Chip', 'Avocado', 'Blueberry', 'Orange', 'Egg', 'Chicken', 'Coconut', 'Asparagus', 'Broccoli',
'Cauliflower', 'Carrot', 'Cucumber', 'Garlic', 'Kale', 'Tomato', 'Salmon', 'Cereal', 'Fruit',
'Bread', 'Cookie', 'Cheese', 'Yoghurt', 'Milk', 'Juice', 'Eggplant', 'Jelly', 'Honey', 'Pizza']
harrypotter_adjectives = ['Magical', 'Swish', 'Flick', 'Transforming', 'Brave', 'Bold', 'Invisible', 'Dead', 'Forbidden',
'Mysterious', 'Secret']
harrypotter_nouns = ['HarryPotter', 'Dumbledore', 'Snape', 'Weasley', 'Hermione', 'McGonagall', 'SiriusBlack',
'Hagrid', 'Hedwig', 'Dobby', 'Voldemort', 'Mad-EyeMoody', 'Malfoy', 'Lovegood', 'Longbottom',
'DeathlyHallows', 'Umbridge', 'Lupin', 'Scamander', 'Nagini', 'Lestrange', 'Dursley', 'Tonks',
'Transfiguration', 'Gryffindor', 'Ravenclaw', 'Slytherin', 'Hufflepuff', 'Hogwarts', 'Magic']
cats_adjectives = ['Fuzzy', 'Furry', 'Agile', 'Clever', 'Precise', 'Patient', 'Hunter', 'Loud', 'Lethal', 'Lazy',
'Predatory', 'Energetic', 'Sleepy', 'Loyal', 'Adorable', 'Cute', 'Passionate']
cats_nouns = ['Feline', 'Cat', 'Meow', 'Purr', 'Hiss', 'Persian', 'Bengal', 'MaineCoon', 'Siamese', 'Sphynx', 'Ragdoll',
'Abyssinian']
dogs_adjectives = ['Friendly', 'Loyal', 'Loud', 'Adorable', 'Cute', 'Passionate', 'Strong', 'Smelly', 'Protective',
'Smart', 'Obedient']
dogs_nouns = ['Woof', 'Dog', 'GermanShepherd', 'Labrador', 'Retriever', 'Husky', 'Poodle', 'Bulldog', 'Pug', 'Chihuahua',
'Rottweiler', 'Maltese', 'Terrier', 'ChowChow']
numbers = random.randint(1,100)
symbols = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '\'', '-', '_', '+', '=', '`', '~', '[', '{', ']', '}', '|',
'<', '.', '>', "https://stackoverflow.com/", '?']
result_normal = random.choice(normal_adjectives) + random.choice(normal_nouns)
result_funny = random.choice(funny_adjectives) + random.choice(funny_nouns)
result_animal = random.choice(animal_adjectives) + random.choice(animal_nouns)
result_landmarks = random.choice(landmarks_adjectives) + random.choice(landmarks_nouns)
result_food = random.choice(food_adjectives) + random.choice(food_nouns)
result_potter = random.choice(harrypotter_adjectives) + random.choice(harrypotter_nouns)
result_cats = random.choice(cats_adjectives) + random.choice(cats_nouns)
result_dogs = random.choice(dogs_adjectives) + random.choice(dogs_nouns)
case = input('Would you like your password in lowercase, uppercase or normal? (lower, upper, normal) ')
number_want = input('Do you want numbers? y/n ')
symbol_want = input('Do you want symbols? y/n ')
theme = input('Enter in the theme for your password (normal/funny/animal/landmarks/food/harry potter/cats/dogs) ')
if case == 'upper':
result_normal = result_normal.upper()
result_funny = result_funny.upper()
result_animal = result_animal.upper()
result_landmarks = result_landmarks.upper()
result_food = result_food.upper()
result_potter = result_potter.upper()
result_cats = result_cats.upper()
result_dogs = result_dogs.upper()
if case == 'lower':
result_normal = result_normal.lower()
result_funny = result_funny.lower()
result_animal = result_animal.lower()
result_landmarks = result_landmarks.lower()
result_food = result_food.lower()
result_potter = result_potter.lower()
result_cats = result_cats.lower()
result_dogs = result_dogs.lower()
if number_want == 'y':
result_normal = result_normal + str(numbers)
result_funny = result_funny + str(numbers)
result_animal = result_animal + str(numbers)
result_landmarks = result_landmarks + str(numbers)
result_food = result_food + str(numbers)
result_potter = result_potter + str(numbers)
result_cats = result_cats + str(numbers)
result_dogs = result_dogs + str(numbers)
if symbol_want == 'y':
result_normal = result_normal + random.choice(symbols)
result_funny = result_funny + random.choice(symbols)
result_animal = result_animal + random.choice(symbols)
result_landmarks = result_landmarks + random.choice(symbols)
result_food = result_food + random.choice(symbols)
result_potter = result_potter + random.choice(symbols)
result_cats = result_cats + random.choice(symbols)
result_dogs = result_dogs + random.choice(symbols)
if theme=='normal':
print(result_normal)
print('Your new password is ' + result_normal)
elif theme=='funny':
print(result_funny)
print('Your new password is ' + result_funny)
elif theme=='animal':
print(result_animal)
print('Your new password is ' + result_animal)
elif theme=='landmarks':
print(result_landmarks)
print('Your new password is ' + result_landmarks)
elif theme=='food':
print(result_food)
print('Your new password is ' + result_food)
elif theme=='harry potter':
print(result_potter)
print('Your new password is ' + result_potter)
elif theme=='cats':
print(result_cats)
print('Your new password is ' + result_cats)
elif theme=='dogs':
print(result_dogs)
print('Your new password is ' + result_dogs)
else:
print(theme + ' is not a valid theme!')
other_p = input('Would you like another password? y/n ')
if other_p == 'y':
password()
start = input('Welcome to the Python Password Generator! Type the word start to start! ')
if start == 'start':
password()
else:
print('Type \'start\' to start, not ' + start)
While this will work once you fix the indentation, this is a terrible implementation. I would suggest setting the theme first, and then adding numbers and symbols. Something like
case = input('Would you like your password in lowercase, uppercase or normal? (lower, upper, normal) ')
number_want = input('Do you want numbers? y/n ')
symbol_want = input('Do you want symbols? y/n ')
theme = input('Enter in the theme for your password (normal/funny/animal/landmarks/food/harry potter/cats/dogs) ')
if theme == 'normal':
password = random.choice(normal_adjectives) + random.choice(normal_nouns)
elif theme == 'funny':
password = random.choice(funny_adjectives) + random.choice(funny_nouns)
elif theme == 'animal':
password = random.choice(animal_adjectives) + random.choice(animal_nouns)
elif theme == 'landmarks':
password = random.choice(landmarks_adjectives) + random.choice(landmarks_nouns)
elif theme == 'food':
password = random.choice(food_adjectives) + random.choice(food_nouns)
elif theme == 'harry potter':
password = random.choice(harrypotter_adjectives) + random.choice(harrypotter_nouns)
elif theme == 'cats':
password = random.choice(cats_adjectives) + random.choice(cats_nouns)
elif theme == 'dogs':
password = random.choice(dogs_adjectives) + random.choice(dogs_nouns)
else:
print(theme + ' is not a valid theme!')
if case == 'upper':
password = password.upper()
if case == 'lower':
password = password.lower()
if number_want == 'y':
password = password + str(numbers)
if symbol_want == 'y':
password = password + random.choice(symbols)
print("Your password is:", password)
other_p = input('Would you like another password? y/n ')
if other_p == 'y':
password()
0
solved What can I do to be able to have numbers with no symbols?