import random
import string
newPassword = input("Do you want a new password?: ")
characters = input("How many characters do you want your new password to have?: ")
def passwordGenerator():
if newPassword.lower() == "yes":
print("Your new password is:")
for i in range(int(characters)):
print(''.join(random.choices(string.ascii_uppercase + string.digits)))
elif newPassword.lower() == "no":
print("Okay, maybe some other time!")
else:
print("Invalid input!")
passwordGenerator()
When I run the code the random characters print out on separate lines, something like:
Y
B
3
R
M
How do I join these characters on a same line to appear as a string?