0

I am writing a code for a password generator.

this is the error I am getting. I don't understand i am i getting this error. Please explain.

enter image description here

for item in range(nr_numbers):
  ran_num = (random.choice(numbers)

for letter in range(nr_letters):
  ran_let = (random.choice(letters)
  
for symbol in range(nr_symbols):
  ran_sym = random.choice(symbols)

this is the code.

I am getting error in the second for loop.

this is the entire code.

import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']

print("Welcome to the PyPassword Generator!")
nr_letters= int(input("How many letters would you like in your password?\n")) 
nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))


for item in range(nr_numbers):
  ran_num = (random.choice(numbers)

for letter in range(nr_letters):
  ran_let = (random.choice(letters)
  
for symbol in range(nr_symbols):
  ran_sym = random.choice(symbols)

#print(password = ran_num + ran_sym + ran_let)

what am I doing wrong?

  • 3
    You are forgetting closing parantheses for `(random.choice(numbers)`...whose opening paranthesis is not really necessary so you can do `random.choice(numbers)` – Mustafa Aydın Apr 22 '21 at 06:45
  • Try writing Python in an editor with a linter, like Spyder. Linters will detect and highlight most syntax errors in your script as you edit it. – BatWannaBe Apr 22 '21 at 06:50

0 Answers0