My program is meant to generate a random password that's 5 characters long using the characters given below in the char variable. The issue is with the randint i believe and cannot figure out why.
from random import randint
print("1. 5 Letters")
enc = input("Please enter your desired option: ")
if enc == "1":
chars = str()
for i in range (1, 6+1):
chars += str("\"~`<>.,?/:;}{[]+_=-)(*&^%$£@!±§qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890" [randint(1, 67)])
print("Your password is: " + chars)
print("\n")
yon = input("Do you want a new password (yes or no): ")
if yon == "yes":
np = int(input("How many new passwords do you want: "))
print("\n")
count = 0
for i in range(1, np+1):
count += 1
chars = str()
for i in range (1, 6 + 1):
chars += "\"~`<>.,?/:;}{[]+_=-)(*&^%$£@!±§qwertyuiopasdfghjklzxcvbnm1234567890" [randint(1, 67)]
print("Your password is : " + str(chars) + " This is password number: " + str(count) + "/" + str(np))
print("\n")
elif yon == "no":
print("Goodbye.")
I get this error after getting to the part where my program generates the additional passwords.
Traceback (most recent call last):
File "/Users/rogerhylton/Desktop/Coding/Python/te.py", line 25, in <module>
chars += "\"~`<>.,?/:;}{[]+_=-)(*&^%$£@!±§qwertyuiopasdfghjklzxcvbnm1234567890" [randint(1, 67)]
IndexError: string index out of range