Idk what needs to be done i just need help

Question:
I just need help. try to run this in a reply because I don’t know what is wrong
Repl link:
not public right now

import random

randomNumber2 = ""

passwordContains = (str("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ`!$%^&*_-=+<>.,?"))
def passwordCreator():   
  randomNumber = random.randint(1,55)   
  randomNumber = randomNumber2
  print(passwordContains[randomNumber,randomNumber2])

passwordCreator()
1 Like

Any particular reason why this “number” is a string?

2 Likes

What are you expecting and what are you getting? You set randomNumber2 to an empty string and randomNumber to that same empty string. Now you check if the password contains… those empty strings, which I believe returns False, but correct me on that. Also, wrapping passwordContains in parentheses does nothing. If you’re getting any errors, please post them here.

3 Likes

So, uhm, there were some errors in the code provided. Additionally, I just want to mention that the code you gave only outputs or should output a single character instead of a “password”. As a result, I remade the code to work properly and also output passwords using a specified length:

import random

passwordContains = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ`!$%^&*_-=+<>.,?"

def passwordCreator(length=6):   
    random_chars = [random.choice(passwordContains) for _ in range(length)]
    return ''.join(random_chars)

random_password = passwordCreator(6)
print(random_password)

I just realized this when I posted it but, when you click run it opens a blank window.
Repl

1 Like

I suppose you have done some command in the shell, possibly installed some HID/screen/website-hosting related packages by poetry/pip.
Yes because now the repl think you are controlling a website, and give you website output.

There is barely any solution except creating another repl and copy everything for this issue, blame VM’s auto output decision for this

1 Like

thank you for helping me

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.